|
| 1 | +import java.util.List; |
| 2 | +import java.util.Random; |
| 3 | +import java.util.stream.Collectors; |
| 4 | + |
| 5 | +/** |
| 6 | + * much character |
| 7 | + * |
| 8 | + * @author Colin "Eric" Reeder :> |
| 9 | + */ |
| 10 | +public class Doge extends Character { |
| 11 | + |
| 12 | + private int riches; |
| 13 | + |
| 14 | + public Doge(String name, int riches, int strength, boolean hasTipBot) { |
| 15 | + super(name); |
| 16 | + this.riches = riches; |
| 17 | + addWeapon(new Paws(strength)); |
| 18 | + if (hasTipBot) { |
| 19 | + addWeapon(new TipBot(2)); |
| 20 | + setEquippedWeapon(1); |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public void describeSelf() { |
| 26 | + System.out.println("such doge. much " + getName() + ". so " + getWealthDescription() + ", very Đ" + riches); |
| 27 | + } |
| 28 | + |
| 29 | + private String getWealthDescription() { |
| 30 | + if (riches < 1000000) { |
| 31 | + return "poor"; |
| 32 | + } |
| 33 | + if (riches > 100000000) { |
| 34 | + return "rich"; |
| 35 | + } |
| 36 | + return "middle-class"; |
| 37 | + } |
| 38 | + |
| 39 | + |
| 40 | + private class Paws extends Weapon { |
| 41 | + Paws(int strength) { |
| 42 | + super("paws", "Somewhat sharp claws, somewhat effective at attacking", strength); |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public boolean useOn(Character target) { |
| 47 | + double damage = ((double)((int)(Math.random() * getBaseDamage() * 10)))/10; |
| 48 | + target.health -= damage; |
| 49 | + System.out.println("*scratch*"); |
| 50 | + System.out.println(target.getName() + " clawed for " + damage + " damage"); |
| 51 | + return true; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + private class TipBot extends Weapon { |
| 56 | + public TipBot(int baseDamage) { |
| 57 | + super("/u/dogetipbot", "Only the best of tip bots", baseDamage); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public boolean useOn(Character target) { |
| 62 | + TipAmount[] amounts = {new TipAmount(4, 240, "megaroll"), |
| 63 | + new TipAmount(98, "dogecar"), |
| 64 | + new TipAmount(4), |
| 65 | + new TipAmount(100), |
| 66 | + new TipAmount(1337, "netcodepool"), |
| 67 | + new TipAmount(1000, "silentshibe"), |
| 68 | + new TipAmount(365, "cake"), |
| 69 | + new TipAmount(98), |
| 70 | + new TipAmount(98), |
| 71 | + new TipAmount(new Random().nextInt(600))}; |
| 72 | + TipAmount chosenAmount = amounts[new Random().nextInt(amounts.length)]; |
| 73 | + boolean verify = Math.random() > 0.3; |
| 74 | + System.out.println(Doge.this.getName()+": +/u/dogetipbot "+target.getName()+" "+chosenAmount.name + (verify?" verify":"")); |
| 75 | + int amount = chosenAmount.getValue(); |
| 76 | + verify = verify || amount >= 1000; |
| 77 | + boolean success = amount <= riches; |
| 78 | + if(success) { |
| 79 | + riches -= amount; |
| 80 | + } |
| 81 | + if(verify && success) { |
| 82 | + System.out.println("dogetipbot: [wow so verify]: "+Doge.this.getName()+" -> "+target.getName()+" Đ"+amount+" Dogecoins"); |
| 83 | + } |
| 84 | + if (target instanceof Doge && Math.random() < 0.95) { |
| 85 | + if(!success) { |
| 86 | + if(Math.random() < 0.9) { |
| 87 | + System.out.println(target.getName()+": I guess it didn't go through..."); |
| 88 | + } |
| 89 | + } |
| 90 | + else { |
| 91 | + if(Math.random() < 0.6) { |
| 92 | + System.out.println(target.getName()+": Thanks!"); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + else if(success) { |
| 97 | + double damage = amount*getBaseDamage()/50; |
| 98 | + System.out.println(target.getName()+" did not collect the tip, and was bitten by the community. -"+damage+" health!"); |
| 99 | + target.health -= damage; |
| 100 | + } |
| 101 | + return success; |
| 102 | + } |
| 103 | + |
| 104 | + private class TipAmount { |
| 105 | + private int min; |
| 106 | + private int max; |
| 107 | + private String name; |
| 108 | + |
| 109 | + public TipAmount(int min, int max, String name) { |
| 110 | + this.min = min; |
| 111 | + this.max = max; |
| 112 | + this.name = name; |
| 113 | + } |
| 114 | + |
| 115 | + public TipAmount(int value, String name) { |
| 116 | + this(value, value, name); |
| 117 | + } |
| 118 | + |
| 119 | + public TipAmount(int value) { |
| 120 | + this(value, value + " doge"); |
| 121 | + } |
| 122 | + |
| 123 | + public int getValue() { |
| 124 | + if(min == max) { |
| 125 | + return min; |
| 126 | + } |
| 127 | + else { |
| 128 | + return min+new Random().nextInt((max-min)/4)*4; |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + @Override |
| 135 | + public int pickTarget(List<Character> potentialTargets) { |
| 136 | + potentialTargets = potentialTargets.stream().filter(character -> character != this).collect(Collectors.toList()); |
| 137 | + int target = super.pickTarget(potentialTargets); |
| 138 | + if(target >= 0) { |
| 139 | + return target; |
| 140 | + } |
| 141 | + else { |
| 142 | + return 0; |
| 143 | + } |
| 144 | + } |
| 145 | +} |
0 commit comments