예제 #1
0
파일: Coin.java 프로젝트: tukkek/javelin
 public static Thing createLevelMoney(int level) {
   level = RPG.d(level);
   int amount = (int) (10 * level * Math.pow(1.1, level));
   if (amount <= 0) {
     amount = 1;
   }
   return createMoney(RPG.d(amount));
 }
예제 #2
0
파일: Coin.java 프로젝트: tukkek/javelin
 /**
  * Rounds money probabilistically
  *
  * @param v Average amount of money
  * @return
  */
 public static int roundMoney(int v) {
   int m = 1;
   while (v > 100) {
     v = v / 10 + (RPG.r(10) < v % 10 ? 1 : 0);
     m = m * 10;
   }
   return v * m;
 }
예제 #3
0
파일: Coin.java 프로젝트: tukkek/javelin
  /**
   * Create a single money stack. Return a rounded amount.
   *
   * @param amount Amount that will be rounded in units of copper.
   */
  public static Thing createMoney(int amount) {
    int type = 0;

    if (amount >= 1000) {
      type++;
    }
    if (amount >= 100) {
      type++;
    }
    if (RPG.d(2) == 1 && amount >= 10) {
      type++;
    }
    for (int i = 0; i < type; i++) {
      amount /= 10;
    }

    if (amount <= 0) {
      amount = 1;
    }

    String name = "copper coin";
    switch (type) {
      case 1:
        name = "silver coin";
        break;
      case 2:
        name = "gold coin";
        break;
      case 3:
        name = "sovereign";
        break;
    }

    Thing t = Lib.create("Barricade");
    t.set("Number", amount);
    return t;
  }