def game(gamestate) : if 'monies' not in gamestate.inventory() or gamestate.inventory()['monies'] == 0 : print ("\"But alas, my dear fellow, why you po. Ain' got none o dat GREEN \n" "na'mean? Ya'll know ain' nobady can play if ya ain' got dem monies!\" \n" "The logic of the man's words slowly penetrate your mind, and you realize \n" "this is not the time for arguing. \n" "\"Get yo ass out theya and kill you some kitty witties o some shit.\"\n" "You forthwith head out to kill some kitty witties or some shit.") return {} else: bet_amount = 0 monies = gamestate.inventory()['monies'] while bet_amount < 1 or bet_amount > monies : print ("\"Ay, how many of your %d pretty farthings wish thee to bet?\" [max %d]"%(monies,monies)) try : bet_amount = int(raw_input()) except KeyboardInterrupt as e : raise e except : print ("\"An integer, Dumas.\"") if gamestate.DEBUG : sys.exit(1) print("\"A bold bet, %d. Now let's see the mettle of your kettle!\""%bet_amount) skill = game_of_skill() skill['bet_amount'] = bet_amount chance = game_of_chance(skill) gamestate.markAchieved('playCarnival')
def game_of_chance(skill) : game_width = 31 game_height = 25 board = [['.' for _ in range(game_width)] for __ in range(game_height)] bins = ['| 10x | 2x | 0x | 2x | 10x |', '-------------------------------'] start_col = game_width/2 - skill['num_right']*3 curr_col = start_col board[0][start_col] = 'o' for i in range(1,game_height) : os.system("clear") move = sample([-1,0,1],1)[0] trace_char = '|' if move == -1 : trace_char = '/' elif move == 1 : trace_char = '\\' board[i-1][curr_col] = trace_char curr_col = max(0,min(curr_col+move,game_width)) board[i][curr_col] = 'o' print '\n'.join(''.join(_) for _ in board) print '\n'.join(bins) time.sleep(0.2) final_bin = curr_col/6 payout = [10,2,0,2,10][final_bin] if payout == 10 : print("\"Brilliant! The maximum payout indeed! Here are your hard earned lucky coins \n" "good sir. Spend them all but naught in the same place! Adieu!\"") elif payout == 2 : print("\"Not bad, not bad. As they say, two winks are as good as a nod to a blind bat. \n" "Spend them all but naught in the same place! Adieu!\"") elif payout == 0 : print("\"Alas poor victim of cruel vagary, you won naught but a sense of loss and regret. \n" "Hone your skills, polish your mind, and return again!\"") gamestate.inventory()['monies'] += -skill['bet_amount']+payout*skill['bet_amount']
def fight(room, noun): room = gamestate.currentRoom() if "enemy" not in room: print( "You brandish a weapon of your choosing, and with a flourish of" "decidedly expert skill, you flail pointlessly in the air. You" "have no doubt been harshly judged by the denizens of your locale." ) return your_stats = {'name': "you", 'hp': 100, 'base_damage': 20} bobos_stats = {'name': "Bobo", 'hp': 25, 'base_damage': 5} you = Actor("you", your_stats) bobo = Actor("Bobo", bobos_stats) enemy = room["enemy"] if enemy.defeated: print "The adage 'beating %s %s that is already dead' comes to mind" % ( enemy.article(), enemy.name) return print "Ohkaaaaaaaay, you decide to attack the %s" % enemy.name print print enemy.art print contestants = [you, bobo] while not enemy.defeated: print "[ You HP=%d, Bobo HP=%d ] vs [ %s HP=%d ]" % ( you.hp, bobo.hp, enemy.name[0], enemy.hp) you_attack = you.attack() print "You attack for %d damage" % you_attack enemy.hit(you_attack) if not bobo.defeated: bobo_attack = bobo.attack() print "Bobo attacks for %d damage" % bobo_attack enemy.hit(bobo_attack) if enemy.defeated: break enemy_attack = enemy.attack() enemy_attack_whom = sample(contestants, 1)[0] print "%s attacks %s for %d damage" % ( enemy.name[0], enemy_attack_whom.name[0], enemy_attack) enemy_attack_whom.hit(enemy_attack) if you.defeated: try: contestants.remove(you) except: pass if bobo.defeated: try: contestants.remove(bobo) except: pass if len(contestants) == 0: break time.sleep(0.5) if enemy.defeated: print "You slew your foe!" if enemy.value != 0: print "ERMAGERD %s dropped %d monies!!1!1!!" % (enemy.name[0], enemy.value) gamestate.addToInventory( "monies", gamestate.inventory()['monies'] + enemy.value) if you.defeated: print "Whelp, guess fighting just wasn't your thing. You're dead." if bobo.defeated: print "But Bobo did not survive to sling poo another day. Poor Bobo." else: print "Since he survived somehow, Bobo dances valiantly on the corpse of the enemy!" print "But this is MAGIC BOBO WORLD AND EVERYTHING IS BACK AS IT WAS"
def fight(room, noun) : room = gamestate.currentRoom() if "enemy" not in room : print ("You brandish a weapon of your choosing, and with a flourish of" "decidedly expert skill, you flail pointlessly in the air. You" "have no doubt been harshly judged by the denizens of your locale.") return your_stats = {'name': "you", 'hp': 100, 'base_damage': 20} bobos_stats = {'name': "Bobo", 'hp': 25, 'base_damage': 5} you = Actor("you",your_stats) bobo = Actor("Bobo",bobos_stats) enemy = room["enemy"] if enemy.defeated : print "The adage 'beating %s %s that is already dead' comes to mind"%(enemy.article(),enemy.name) return print "Ohkaaaaaaaay, you decide to attack the %s"%enemy.name print print enemy.art print contestants = [you,bobo] while not enemy.defeated : print "[ You HP=%d, Bobo HP=%d ] vs [ %s HP=%d ]"%(you.hp,bobo.hp,enemy.name[0],enemy.hp) you_attack = you.attack() print "You attack for %d damage"%you_attack enemy.hit(you_attack) if not bobo.defeated : bobo_attack = bobo.attack() print "Bobo attacks for %d damage"%bobo_attack enemy.hit(bobo_attack) if enemy.defeated : break enemy_attack = enemy.attack() enemy_attack_whom = sample(contestants,1)[0] print "%s attacks %s for %d damage"%(enemy.name[0],enemy_attack_whom.name[0],enemy_attack) enemy_attack_whom.hit(enemy_attack) if you.defeated : try : contestants.remove(you) except : pass if bobo.defeated : try : contestants.remove(bobo) except : pass if len(contestants) == 0 : break time.sleep(0.5) if enemy.defeated : print "You slew your foe!" if enemy.value != 0 : print "ERMAGERD %s dropped %d monies!!1!1!!"%(enemy.name[0],enemy.value) gamestate.addToInventory("monies",gamestate.inventory()['monies']+enemy.value) if you.defeated : print "Whelp, guess fighting just wasn't your thing. You're dead." if bobo.defeated : print "But Bobo did not survive to sling poo another day. Poor Bobo." else : print "Since he survived somehow, Bobo dances valiantly on the corpse of the enemy!" print "But this is MAGIC BOBO WORLD AND EVERYTHING IS BACK AS IT WAS"