Esempio n. 1
0
 // Calculate funds available
 public static int getMoney(Thing t) {
   Thing[] cash = t.getFlaggedContents("IsMoney");
   int tot = 0;
   for (Thing element : cash) {
     tot += valueOf(element);
   }
   return tot;
 }
Esempio n. 2
0
 public static void removeMoney(Thing person, int amountInCoppers) {
   if (amountInCoppers <= 0) {
     addMoney(person, -amountInCoppers);
     return;
   }
   int funds = getMoney(person) - amountInCoppers;
   Thing[] cash = person.getFlaggedContents("IsMoney");
   // TODO: make this spend coins effectively
   for (Thing element : cash) {
     element.remove();
   }
   if (funds > 0) {
     addMoney(person, funds);
   }
 }