def __init__(self, name, health=90.0, strength=60.0, dexterity=20.0, accuracy=30.0, charisma=50.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['headbutt'] = [self.headbutt, 7] self.moves['slam'] = [self.slam, 5] self.moves['chomp'] = [self.chomp, 3]
def __init__(self, name, health=60.0, strength=70.0, dexterity=40.0, accuracy=40.0, charisma=40.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['tail whip'] = [self.tail_whip, 9] self.moves['rabid slash'] = [self.rabid_slash, 4] self.moves['claw'] = [self.claw, 7]
def __init__(self, name, health=50.0, strength=50.0, dexterity=50.0, accuracy=50.0, charisma=50.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['scratch'] = [self.scratch, 12] self.moves['timed stab'] = [self.timed_stab, 4] self.moves['gnaw'] = [self.gnaw, 3]
def __init__(self, name, health=40.0, strength=40.0, dexterity=50.0, accuracy=50.0, charisma=70.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['lick'] = [self.lick, 10] self.moves['snuggle'] = [self.snuggle, 5] self.moves['copycat'] = [self.copycat, 1]
def __init__(self, name, health=20.0, strength=30.0, dexterity=90.0, accuracy=50.0, charisma=60.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['bite'] = [self.bite, -1] self.moves['quick slash'] = [self.quick_slash, 12] self.moves['leap'] = [self.leap, 6] self.moves['flurry'] = [self.flurry, 4]
def burrow(self, tempo, enemy): '''Burrow is a low damage move which throws your opponent off, gaining 10 tempo, and 10 dexterity. (Even on a miss)''' dmg = self.stats['str']*.4 crit = Rodent.crit(self.stats['acc']) dmg *= crit self.stats['dex'] += 10 return (dmg, 10, crit, 'The mole got into an advantageous position!\n*')
def whirlwind(self, tempo, enemy): '''Whirlwind is a wild spin move, launching quills all around. Deals 2.5x damage, but reduces your own strength by 15%. 20% chance to miss. (-30 tempo)''' dmg = self.stats['str'] *2.5 crit = Rodent.crit(self.stats['acc'], miss_chance=20) dmg *= crit self.stats['str'] *= .85 return (dmg, -30, crit, 'The porcupine lost some of its spikes. *')
def headbutt(self, tempo, enemy): '''Headbutt is a regular damage, 5 tempo cost attack, with zero chance to crit. Deals extra damage when behind on tempo.''' dmg = self.stats['str'] if tempo < 0: dmg += tempo * -.8 crit = Rodent.crit(self.stats['acc'], crit_chance=0) dmg *= crit return (dmg, -5, crit, '')
def double_swipe(self, tempo, enemy): '''Double swipe is an attack using both your claws, giving you two opportunities to miss, or crit. Each attack does regular damage. 20% miss, 5% crit. Loses 20 tempo.''' dmg1, dmg2 = self.stats['str'], self.stats['str'] crit1 = Rodent.crit(self.stats['acc'], miss_chance=20) crit2 = Rodent.crit(self.stats['acc'], miss_chance=20) dmg1 *= crit1 dmg2 *= crit2 sp = '' if crit1 == 0: sp += 'First hit missed!\n' elif crit1 == 2: sp += 'First hit crit!\n' if crit2 == 0: sp += 'Second hit missed!\n' elif crit2 == 2: sp += 'Second hit crit!\n' return (dmg1 + dmg2, -20, 1, sp)
def claw(self, tempo, enemy): '''Claw is a basic slashing attack which costs 5 tempo. Deals 90% damage, with 10% miss chance, 45% crit chance, with 1.5x damage.''' dmg = self.stats['str'] * .9 crit = Rodent.crit(self.stats['acc'], miss_chance=10, crit_chance=45, crit_dmg=1.5) dmg *= crit return (dmg, -5, crit, '')
def power_punch(self, tempo, enemy): '''Power punch is a high damage, -20 tempo move, which increases your strength by 10. 15% chance to miss, 10% chance to crit.''' dmg = self.stats['str'] * 1.6 crit = Rodent.crit(self.stats['acc'], crit_chance=10, miss_chance=15) dmg *= crit if crit > 0: self.stats['str'] += 10 return (dmg, -20, crit, 'The mole is motivated by the power!\n*') else: return (dmg, -20, crit, '')
def chomp(self, tempo, enemy): '''Chomp is a very risky move, with 30% chance to miss. -17 tempo. On hit, you lift the enemy up with your jaws, dealing high damage and decreasing their accuracy by 10.''' dmg = self.stats['str'] * 2 crit = Rodent.crit(self.stats['acc'], miss_chance=30) if crit > 0: enemy.stats['acc'] -= 10 return (dmg, -17, crit, enemy.name + ' is lifted into the air!\n' + repr(enemy)) dmg *= crit return (dmg, -17, crit, '')
def copycat(self, tempo, enemy): '''Copy cat steals a random move from your opponent. Deals no damage. 0 tempo cost. 10% miss chance.''' crit = Rodent.crit(self.stats['acc'], miss_chance=10, crit_chance=0) if crit != 0: m = choice(list(enemy.moves.keys())) self.moves[m] = enemy.moves[m] del (self.moves['copycat']) return (0, 0, crit, 'Successfully copied ' + m + '.') else: return (0, 0, crit, '')
def timed_stab(self, tempo, enemy): '''Timed stab is a precise move with 15 tempo loss, which deals extra damage based on your current tempo. 0% miss chance, crit chance equal to tempo.''' dmg = self.stats['str'] if tempo > 0: dmg += tempo * 2 if tempo > 100: tempo = 100 crit = Rodent.crit(self.stats['acc'], miss_chance=0, crit_chance=tempo) dmg *= crit return (dmg, -15, crit, '')
def leap(self, tempo, enemy): '''leap is a risky move which has 30% to miss and 30% to crit. On a miss, lose 30 tempo, on a crit gain 30 tempo. Otherwise, gain 20.''' dmg = self.stats['str'] crit = Rodent.crit(self.stats['acc'], miss_chance=30, crit_chance=30) dmg *= crit tc = 20 if crit == 0: tc = -30 if crit == 2: tc = 30 return (dmg, tc, crit, '')
def snuggle(self, tempo, enemy): '''Snuggle is an extremely weak attack that lowers your opponents strength by 20%. Gains 10 tempo. However, on a miss (20%) nothing happens and you lose 20 tempo.''' dmg = self.stats['str'] * .2 crit = Rodent.crit(self.stats['acc'], miss_chance=20) dmg *= crit if crit == 0: return (dmg, -20, crit, '') else: enemy.stats['str'] *= .8 return (dmg, 10, crit, enemy.name + ' doesn\'t want to hurt ' + self.name + ' as much.\n' + repr(enemy))
def tail_whip(self, tempo, enemy): '''Tail whip is a low damage move which regains 5 tempo, and on crit ensares the enemy, halving their dexterity. 10% miss chance, 20% crit chance.''' dmg = self.stats['str'] * .5 crit = Rodent.crit(self.stats['acc'], crit_chance=20, miss_chance=10) dmg *= crit if crit > 1: enemy.stats['dex'] *= .5 return (dmg, 5, crit, 'The tail catches its target and wraps around!\n' + repr(enemy)) else: return (dmg, 5, crit, '')
def lick(self, tempo, enemy): '''Lick deals damage proportional to your charisma, and lowers your opponents accuracy and raises your accuracy each by 10%. -10 tempo. ''' dmg = self.stats['chr'] * .9 crit = Rodent.crit(self.stats['acc']) dmg *= crit if crit != 0: self.stats['acc'] *= 1.1 enemy.stats['acc'] *= .9 return (dmg, -10, crit, 'Eww, it licked em, changing each rodent\'s accuracy.\n' + repr(enemy) + '\n*') else: return (dmg, -10, crit, '')
def rabid_slash(self, tempo, enemy): '''Rabid slash is an unwieldy (-30 tempo), but powerful move with high miss and crit chance, reducing the opponents strength by 5. 15% miss chance, 20% crit chance. 2.5x crit damage.''' dmg = self.stats['str'] * 2 crit = Rodent.crit(self.stats['acc'], miss_chance=15, crit_chance=20, crit_dmg=2.5) dmg *= crit if dmg > 0: enemy.stats['str'] -= 5 return (dmg, -30, crit, 'The wound is infected and ' + enemy.name + ' is weakened!\n' + repr(enemy)) else: return (dmg, -30, crit, '')
def flurry(self, tempo, enemy): '''Flurry consists of a series of lightning-fast attacks, dealing damage based on your strength. The higher your dexterity is, the more attacks you get. Each has a 15% chance to miss or crit. -40 tempo.''' dmg = self.stats['str'] total = 0 misses = 0 crits = 0 for i in range(int(self.stats['dex'] // 12)): crit = Rodent.crit(self.stats['acc'], miss_chance=15, crit_chance=15) total += dmg * crit if crit == 0: misses += 1 if crit == 2: crits += 1 return (total, -40, 1, str(int(self.stats['dex'] // 10)) + ' swipes of the claw! ' + str(misses) + ' misses, and ' + str(crits) + ' critical hits.')
def dojo(rod: Rodent): print( 'You enter the dojo, and see four red pandas each practicing different moves, as well as some mice meditating in the corner.' ) #generate moves while len(ShadyRoach.dojo_dict) < 4: r_move = random.choice(list(moves.MOVES.keys())) while r_move in ShadyRoach.dojo_dict: r_move = random.choice(list(moves.MOVES.keys())) ShadyRoach.dojo_dict[r_move] = moves.MOVES[r_move] if len(rod.moves.keys()) >= 5: print('Looks like you have maximum capacity moves.') c = select('Would you like to meditate or leave?', 'meditate', 'leave') else: c = select('Would you like to meditate or learn a new move?', 'meditate', 'learn') if c == 'learn': h_dict = {} for name, (f, num, cost) in ShadyRoach.dojo_dict.items(): h_dict[name] = (f.__doc__ + "\ncost = $" + str(cost), num) m = select('What move would you like to learn?', *ShadyRoach.dojo_dict.keys(), info_full=h_dict) if rod.money >= ShadyRoach.dojo_dict[m][2]: rod.money -= ShadyRoach.dojo_dict[m][2] print('Learned ' + m + '! new balance: $' + str(rod.money)) rod.moves[m] = ShadyRoach.dojo_dict[m][0:2] ShadyRoach.dojo_dict.clear() else: print('You do not have enough money for that move.') wait() elif c == 'meditate': h_dict = {} for name, (f, num) in rod.moves.items(): h_dict[name] = (f.__doc__, num) c = select('Which move would you like to forget?', *rod.moves.keys(), info_full=h_dict) del (rod.moves[c]) else: wait('You leave the dojo')
def scratch(self, tempo, enemy): '''Scratch is a reliable, yet weak move which gains 10 tempo. Deals 90% damage. 1% miss chance, 1% crit chance.''' dmg = self.stats['str'] * .5 crit = Rodent.crit(self.stats['acc'], crit_chance=1, miss_chance=1) dmg *= crit return (dmg, 10, crit, '')
def __init__(self, name, health=70.0, strength=70.0, dexterity=60.0, accuracy=20.0, charisma=40.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['power punch'] = [self.power_punch, 5] self.moves['burrow'] = [self.burrow, 4] self.moves['double swipe'] = [self.double_swipe, 3]
def __init__(self, name, health=60.0, strength=80.0, dexterity=40.0, accuracy=50.0, charisma=10.0, ai=False): Rodent.__init__(self, name, health, strength, dexterity, accuracy, charisma, ai) self.moves['bump'] = [self.bump, 7] self.moves['whirlwind'] = [self.whirlwind, 5] self.moves['defensive stance'] = [self.defensive_stance, 5]
def defensive_stance(self, tempo, enemy): '''Defensive stance uses your quills to reflect damage equal to your opponents strength against him. 10 tempo cost.''' dmg = enemy.stats['str'] crit = Rodent.crit(self.stats['acc']) dmg *= crit return (dmg, -10, crit, '')
def slam(self, tempo, enemy): '''Slam is a powerful but costly move. It deals triple damage, but costs 45 tempo. Crit damage: * 1.5. Miss chance: 10%.''' dmg = self.stats['str'] * 3 crit = Rodent.crit(self.stats['acc'], crit_dmg=1.5, miss_chance=10) dmg *= crit return (dmg, -45, crit, '')
def bump(self, tempo, enemy): '''Bump is a quick ram into the enemy. 1.35x damage, 13.5% chance to crit, only 1.35x damage on crit. Loses 15 tempo.''' dmg = self.stats['str'] * 1.35 crit = Rodent.crit(self.stats['acc'], crit_chance=13.5, crit_dmg = 1.35) dmg *= crit return (dmg, -15, crit, '')
def fight(r1: Rodent, r2: Rodent): free_hit = False rodent1 = r1.clone() rodent2 = r2.clone() tempo = 0 turn = 1 rodent1.health = rodent1.stats['hp']*10 rodent2.health = rodent2.stats['hp']*10 print(repr(rodent1)) print(repr(rodent2)) print() def do_move(rod1, rod2): nonlocal tempo print(str(rod1) + ' attacking ' + str(rod2)) if tempo >= 0: print('Current tempo: ' + str(tempo) + ' in the favor of ' + rod1.name + ', out of ' + str(int(50*rod2.stats['dex']/rod1.stats['dex']))) else: print('Current tempo: ' + str(tempo*-1) + ' in the favor of ' + rod2.name + ', out of ' + str(int(50*rod1.stats['dex']/rod2.stats['dex']))) print(rod1.name + ' health points: ' + str(round(rod1.health, 2))) print(rod2.name + ' health points: ' + str(round(rod2.health, 2))) print() damage, tempo_change, crit, special = rod1.attack(tempo, rod2) rod2.health -= damage if not free_hit: tempo += tempo_change if free_hit and tempo_change > 0: tempo += tempo_change print() if crit > 1: print('Critical hit!') if crit == 0: print('Swing and a miss!') else: print(rod1.name + ' dealt ' + str(round(damage, 2)) + ' points of damage.') def fix_stats(r): for k, v in r.stats.items(): if v < 0: r.stats[k] = 1 fix_stats(rod1) fix_stats(rod2) if len(special) > 0 and special[-1] == '*': print(special[:-1] + repr(rod1)) else: print(special) print() while rodent1.health > 0 and rodent2.health > 0: if turn > 0: if tempo*-1 >= 50*rodent1.stats['dex']/rodent2.stats['dex']: print(rodent1.name + ' fell behind on tempo! It\'s turn is skipped.') tempo += int(50*rodent1.stats['dex']/rodent2.stats['dex']) free_hit = True else: do_move(rodent1, rodent2) free_hit = False else: if tempo*-1 >= 50*rodent2.stats['dex']/rodent1.stats['dex']: print(rodent2.name + ' fell behind on tempo! It\'s turn is skipped.') tempo += int(50*rodent2.stats['dex']/rodent1.stats['dex']) free_hit = True else: do_move(rodent2, rodent1) free_hit = False turn *= -1 tempo *= -1 wait() print('\n'*5) if rodent1.health < rodent2.health: return rodent2 else: return rodent1
def quick_slash(self, tempo, enemy): '''Quick slash is a slightly less damaging move, which gains 15 tempo. 20% chance to crit.''' dmg = self.stats['str'] * .8 crit = Rodent.crit(self.stats['acc'], crit_chance=20) dmg *= crit return (dmg, 15, crit, '')
def gnaw(self, tempo, enemy): '''Gnaw is a slow, high damaging move. 23 tempo loss, and deals double damage.''' dmg = self.stats['str'] * 2 crit = Rodent.crit(self.stats['acc']) dmg *= crit return (dmg, -23, crit, '')