示例#1
0
文件: main.py 项目: LeonP92/GTM
def main(): 
	userChoice = "" #User choice variable
	# before the game start the main menu pops up asking if you want to start a new game, continue, help, or quit the game 
	game.greetings() 
	while 1:  #Main while loop 
		print(fight.hilight("\nWhat are you trying to do home boy??",'36',1)) 
		userChoice = game.usermove(defchoice, 0) #Gets user choice
		if userChoice == 'a': #Gets into a random fight 
			fight.fight("street", int(game.parse("Level"))*80, int(game.parse("Level"))*150)
		elif userChoice == 'b': #Robs chances could also lead into a fight
			robnrest.rob("street")
		elif userChoice == 'c': #Misison
			#Makes sure user really wants to go into a mission
			sure = raw_input(fight.hilight("Are you sure you want to go into the mission? Most mission are hard unless you're a certain level... Check the help for more info ",'31',1)+fight.hilight("[Press Y if you want to start the mission and any other key to run away like a wimp] ",'33',0)).lower()
			if sure == 'y': #If user is sure call on the mission function
				mission.mission(int(game.parse("Mission")))
			time.sleep(2)
		elif userChoice == 'd': #Shows shop
			shop.showshop(0)
		elif userChoice == 'e': #Rests and restores hp
			robnrest.rest()
		elif userChoice == 'i': #Shows character info
			game.displayfile("character.txt")
		elif userChoice == 'q':
			game.initopts() #Quits out of the game 
示例#2
0
def move_hero(board, player, y, x, exit_y, exit_x):
    old_player = "."
    old_y = y
    old_x = x
    board[y][x] = player
    stats = import_statistics("hero_stats.csv")
    enemy_stats = import_statistics("enemy_stats.csv")
    while board[exit_y][exit_x] != player:
        key = getch()

        if key == "q":
            exit()
        if key == "i":
            print_statistics("hero_stats.csv")
            time.sleep(3)
        if key == "w":
            y -= 1
            old_y = y + 1
            old_x = x
        elif key == "s":
            y += 1
            old_y = y - 1
            old_x = x
        elif key == "a":
            x -= 1
            old_x = x + 1
            old_y = y
        elif key == "d":
            x += 1
            old_x = x - 1
            old_y = y

        if board[y][x] != "." and board[y][x] != "R" and board[y][x] != "F" and board[y][x] != "T" and board[y][x] != player and board[y][x] != "%":
            print("Auc! Nabiles sobie guza!")
            x = old_x
            y = old_y
            continue
        elif board[y][x] == "R":
            item_gather(board, 13, 59)
        elif board[y][x] == "F":
            item_gather(board, 3, 40)
        elif board[y][x] == "T":
            fight.fight(stats, enemy_stats)
        elif board[y][x] == "%":
            coldwarm.main()


        board[y][x] = player
        board[old_y][old_x] = old_player
        print_board(board)
    def enter(self):
        print(
            dedent(f'''
        you didn't anticipate to face that kind of man, and the fact that the
        next opponent will be stronger and fiercer than the last one makes you
        can't calm your mind. While tending your wounds, you can't get rid off
        that concern... as the result, you don't have a proper rest (restore
        25 HP). You are still with your wornout armor and sword, you cannot
        fathom why they didn't give you a new one, but screw them, you just
        have to kill your enemy to stay alive, it's that simple... You already
        stand in front of the gate without the game master saying...
        KRAKKK!!! the gate is open...
        Not like the last time, now your enemy is kinda... too small,
        even he looks like a dwarf, for a moment you feel a relief, but...

        '''))

        if player.hp >= char.vit(job) - 25 and player.hp <= char.vit(job):
            player.hp = char.vit(job)

        else:
            player.hp += 25

        enemy3 = char.Enemy("Palkon the Deadly", 100, 25)

        fight3 = fight(player, enemy3, death)

        return 'last_stage'
    def enter(self):
        print(
            dedent('''
        You don't care anymore, you don't care wether you will be alive of
        dead after this last fight, your enemy is the renown "Edi the
        Invicible". the chance of you winning, or maybe even living after your
        confrontation with him is slim to none, but there is nothing you can
        do. As a slave you can't do anything really, accept your fate is the
        only choice you have.... and surely they don't give you any time to
        rest, but strangely enough, for this last fight, you
        are given a new pair of equipments, a set of steel armor (+50 HP) and
        a new shining sword (+10 atk) instead. Now you look like a real
        warrior at last... finally the game master calls you, you then go to
        the gate and
        wait patienly until the get open......
        KRAKKK!!! the gate is open...
        you can hear the loud shouting around the arena, but the one thing
        that catches your sense the most is the presence that "Edi the
        Invicible" emmitted, is so great you almost run with your tail between
        your legs, but you can't.....
        '''))

        player.hp += 50
        player.atk += 10

        enemy4 = char.Enemy("Edi the Invicible", 200, 35)

        fight4 = fight(player, enemy3, death)

        return 'victory'
示例#5
0
文件: game_file.py 项目: aubinh/CS301
def attack_command(holder):
  if holder[0]=="attack":
    if location.baddies:
      import fight
      win=fight.fight(int(location.baddies.damage) + int(location.baddies.health))
      print"="*11+"BATTLE"+"="*11
      '''
      neitherdead=0
      if user.shield!= None:
        yourhealth=(int(user.health) + int(user.shield.power))*int(player["Hmultiplier"])*(user.level+100)/90
      else:
        yourhealth=(int(user.health))*int(player["Hmultiplier"])*(user.level+100)/90
      if user.weapon!= None:
        yourdamage=(int(user.weapon.power)+user.damage)*int(player["Dmultiplier"])*(user.level+100)/90
      else:
        yourdamage=(user.damage)*int(player["Dmultiplier"])*(user.level+100)/90
      monsterdamage=int(location.baddies.damage)
      monsterhealth=int(location.baddies.health)
      while neitherdead==0:
        monsterhealth=monsterhealth-yourdamage
        if user.weapon!= None: 
          print("you just attacked "+str(location.baddies.name) +" with: "+ str(user.weapon.name))
        else:
          print("you just attacked "+str(location.baddies.name) +" with: your mighty fists")
      '''
      if win==True:
        print("you have just killed "+str(location.baddies.name))
        
        player["points"]=player["points"]+int(location.baddies.health)
        print"*"*35
        print("you have found :")
        for item in location.baddies.contents:
          if item==None:
            break
          
          print("a(n) "+str(item))
          print("\tDescription: "+str(item.description)+"\n")
          user.contents.append(item)
        print"*"*35
        level_upper(int(location.baddies.health),int(location.baddies.damage))
        location.baddies=None
        i=raw_input("Press Enter to continue")
        for i in range(50):
          print
        
      #yourhealth=yourhealth-monsterdamage
      #print(str(location.baddies.name)+" just attacked you for: "+str(monsterdamage))
    if win==False:
      print("you have just been killed by "+str(location.baddies.name))
      player["lives"]=player["lives"]-1
      if player["lives"]<0:
        response="dfhsergghj"
        
      print("you only have: "+str(player["lives"])+" lives/life left")
      i=raw_input("Press Enter to continue")
      for i in range(50):
        print 
示例#6
0
	def start_fight(self, id1, id2):
		c1 = self.find_context_by_id(id1)
		c2 = self.find_context_by_id(id2)
		if c1 and c2 and (c1 != c2) and not c1.fight and not c2.fight:
			f = fight.fight(c1,c2)
			self.fights.append(f)
			return 1
		else:
			return 0
示例#7
0
def start_combat(player, enemy):
    fighter = player

    a = select('Would you like to befriend ' + enemy.name + '?', 'yes', 'no')
    if a == 'yes':
        if fighter.befriend(enemy):
            wait('You successfully befriended ' + enemy.name +
                 '!\n Friends: ' + ', '.join(fighter.get_friends()))
            return 0
        else:
            print('You failed to befriend your enemy. You must fight!')
    if len(fighter.friends) > 0:
        a = select('Would you like to fight by yourself, or tap a friend in?',
                   'self', 'friend')
    else:
        a = 'self'
    if a == 'friend':
        h_dict = {}
        for i in fighter.friends:
            h_dict[i.name] = repr(i), -1
        f = select('Which friend?',
                   *fighter.get_friends(),
                   info_full=h_dict,
                   index=True)
        fighter = fighter.friends[f]
        fighter.ai = False
        print('Selected ' + str(fighter) + ' to fight.')
    else:
        print('You will fight.')
    if fight(fighter, enemy) == fighter:
        print(random_death(enemy))
        if enemy.level < fighter.level:
            loot = enemy.money
        else:
            loot = enemy.money + (enemy.level - fighter.level) * 2
        print(fighter.name + ' found ' + str(loot) +
              ' shiny trinkets from looting ' + fighter.name + '\'s corpse.')
        fighter.money += loot
        wait()
        return 1
    else:
        if fighter == player:
            print(enemy.name + ' beats you within an inch of your life.')
            if player.money < 10:
                print('You wake up, missing all ' + str(player.money) +
                      ' of your scraps.')
                player.money = 0
                wait()
            else:
                print('You wake up, $10 lighter.')
                player.money -= 10
                wait()
        else:
            print(random_death(fighter))
            del (player.friends[f])
            wait('Mourn your friend\'s passing')
        return -1
def run_tournament(combatants, log_results=True, spectate=False, tournament_start=False):

    if len(combatants) > 2:
        split = int(len(combatants)/2)

        bracket_one = combatants[:split]
        bracket_two = combatants[-split:]

        winner = fight(run_tournament(bracket_one), run_tournament(bracket_two), log_results=log_results, spectate=spectate)
        constants.ROUND_NUMBER = constants.ROUND_NUMBER + 1

        return winner

    elif len(combatants) == 2:
        print("Going in")
        winner = fight(combatants[0], combatants[1], log_results=log_results, spectate=spectate)
        constants.ROUND_NUMBER = constants.ROUND_NUMBER + 1
        print(winner.name)
        return winner
示例#9
0
 def search(self, s):
     i = random.randrange(len(self.homes))
     if self.homes[i] is None:
         s.homeless = False
         self.homes[i] = s
     else:
         wl = fight(self.homes[i], s)
         self.homes[i] = wl[0]
         wl[0].homeless = False
         wl[1].homeless = True
         self.biddiff.append(wl[2]-wl[3])
示例#10
0
文件: robnrest.py 项目: LeonP92/GTM
def rob(environment):
	if random.randrange(0,11)>8:
		print(fight.hilight("You successfully robbed someone!",'32',1))
		addmoney(1, 50)
		return -1
	else:
		print(fight.hilight("Uh oh...\nStranger: Hey punk, who do you think you're robbing?!... PREPARE TO GET YO KNEES BUSTED SON!",'31',1))
		time.sleep(2)
		# If you won the fight, get stuff from guy
		if fight.fight(environment, int(game.parse("Level"))*75, int(game.parse("Level"))*150):
			return -1
		else:
			return 0
示例#11
0
文件: game.py 项目: dem-ola/fufu
def bell(angle, at, df, normal_speed):
    ''' bell rings - fight '''
    shift = 60
    revs = 3
    loop = int(360 / shift * revs)
    for _ in range(loop):
        angle += shift
        at.setheading(angle)
        df.setheading(angle)
    winner, loser = fight(at, df)
    winner.speed(normal_speed)
    if winner.weapon is not None:
        winner.weapon.forward(0) # so weapon shows atop
    print(winner, 'wins')
    print('scores:', winner.battle_score, 'to', loser.battle_score)
    return winner, loser
示例#12
0
def map2_action(char_alloved, board, x, y):
    print(x, y)
    board, x, y, button = get_action(char_alloved, board, x, y, "maps/map2.txt")
    inv = change_files.import_inventory('test_inventory.csv')
    stats = change_files.import_stats('stats.csv')
    change_files.level_up(stats['Exp'], stats['Level'])

    if board[y][x] == char_alloved[11]:
        print('Stay there, kurwa!')
        sleep(0.5)
        enemy_health = fight.fight(25, 25, 5, 5, 25, x, y)
        if enemy_health <= 0:
            board[y][x] = 'x'
            board_change('maps/map2.txt', x, y)
            print('enemy is beaten \n plus 75XP')
            sleep(0.5)
        x, y = back(button, x, y)
        board_change('maps/map2.txt', x, y)

    if board[y][x] == 'x':
        x, y = back(button, x, y)
        board_change('maps/map2.txt', x, y)
        print('Im sorry, dont kill me!')
        sleep(0.5)

    if board[y][x] == '⚗':
        x, y = back(button, x, y)
        board_change('maps/map2.txt', x, y)
        print('good luck')
        sleep(0.5)

    if board[y][x] == char_alloved[13] or board[y][x] == char_alloved[14]:
        stats['Health'] = stats['Max health']
        change_files.add_to_stats(stats, 0, 0, 0, 0, 0, 0)
        print('Health is back')
        sleep(0.2)

    if board[y][x] == '&':
        x, y = back(button, x, y)
        board_change('maps/map2.txt', x, y)
        print('I have to drink...')
        sleep(0.5)

    if board[y][x] == char_alloved[10]:
        return 3, x, y
    else:
        return 2, x, y
    def enter(self):
        print(
            dedent(f'''
        Now you are in the Colloseum, you don't have any idea what to expect.
        Suddenly your name is called by someone, turn out, it is the game
        master, he tells you to take some equipment before you enter the arena,
        so you go to the armory, there are not a lot of equipments there, just
        a basic one, so you decide to take a set of light armor and a worn out
        sword...
        Now you are ready for your first fight. You stand in front of the
        gate, and you can hear a glimps of the shouting from the spectators...
        KRAKKK!!! the gate is open...
        you rush into the arena and find your first enemy...
        '''))

        enemy1 = char.Enemy("Puki the Foul", 75, 10)

        fight1 = fight(player, enemy1, death)

        return 'stage2'
    def enter(self):
        print(
            dedent(f'''
        "That was some fighting you put out there" says the game master, you
        just ignore him and try to tend your wound. Eventhough that fight was
        not that hard, you still have some injury ({player.hp} HP left). After
        a short rest (get to full hp), you gain your energy back, and the game
        master calls you again, he tells you to get ready for the next
        fight... You go to the gate and prepare your body and mind to face the
        next enemy...
        KRAKKK!!! the gate is open...
        this time, you can see clearly what your opponent looks like, he is
        HUGE....
        '''))
        player.hp = char.vit(job)

        enemy2 = char.Enemy("Tobron the Giant", 150, 15)

        fight2 = fight(player, enemy2, death)

        return 'stage3'
示例#15
0
def empirical_attacker_odds(attacking_armies, defending_armies, \
    attacking_armies_to_use, repeats=1000):

    attacker_wins = 0
    for i in range(repeats):
        # the '_' is a convention that means that we don't care about that
        # thing the function we are calling is returning.

        # functions can return more than one thing. you will see in fight.py
        # that it returns three things, which is why we have three things 
        # separated by commas here.

        # attacker_must_move is 0 if the defender wins, otherwise non-zero.
        _, _, attacker_must_move = fight(attacking_armies, defending_armies, \
            attacking_armies_to_use=attacking_armies_to_use, verbose=False)

        if attacker_must_move > 0:
            attacker_wins = attacker_wins + 1

    attacker_odds = attacker_wins / repeats
    return attacker_odds
示例#16
0
        print(
            'Russ: The tempo is sort of like this subtle tug-of-war between you and your opponent. Powerful moves will cost more tempo, causing you to fall behind your opponent.'
        )
        print(
            'Russ: If you fall behind the tempo limit, calculated via a ratio of each rodent\'s dexterity, your turn will be skipped, and your opponent gets a free hit, with zero tempo cost.'
        )
        print(
            'Russ: The same goes the other way, so try to time your moves correctly, and wear out your opponent. '
        )
        wait()
        print(
            'Russ: That should be enough for now. Look at that baby there, why don\'t you challenge it to a fight, using what i told you?'
        )
        wait('You go up and challenge the tiny mouse.')
        clear()
        if fight(player, mouse.Mouse(name(), 40, 40, 40, 40, 40,
                                     ai=True)) == player:
            print('The mouse falls to the ground, limp, covered in blood.')
            print('Russ: Nice kill! Now you\'re getting it!')
        else:
            print(
                'Russ: Wow, that\'s pretty embarassing. Well, it\'s okay. You will learn.'
            )
        print(
            'Russ: Here, I gotta go fight that capybara that was looking at me funny. Here are some shiny scraps, that\'s currency around here.'
        )
        player.money += 10
        print('He hands you 10 random trinkets covered in dirt. Balance: ' +
              str(player.money))

        wait()
示例#17
0
def overlap(step, colonies, relationship, inner_step):
    '''
    Describe:
    Check if two colonies overlap with each other or not. If they overlap, synergistic colonies will merge into a big one. Otherwise,
    they will fight until they do not overlap.


    Positional arguments:
    -> self:                
    -> colonies:                a dictionary containing all colonies during the simulation
    -> relationship:            relationship between two colonies
    -> inner_step:              pseudo steps


    Return:
    None
    '''

    # EXIT. Only one colony left.
    if len(colonies.keys()) <= 1:

        check_strength(step, colonies)

        return inner_step

    # If fewer than three bacteria are in one colony, they cannot form a well-defiend convexhull.
    # Another algorithm will be applied.
    colonies_keys_1 = list(colonies.keys())
    colonies_keys_2 = deepcopy(colonies_keys_1)

    for colony in colonies_keys_2:

        if len(colonies[colony].points) <= 3 and len(
                colonies[colony].points) > 0:

            colonies_keys_1.remove(colony)

        elif len(colonies[colony].points) == 0:

            del colonies[colony]
            colonies_keys_1.remove(colony)

        else:

            pass

    # If the colony does not contain any bacteria, then delete it from the colonies

    # Combinations between two arbitrary colonies
    comb = list(combinations(colonies_keys_1, 2))

    vertices_set = dict()
    overlap_colony = list()

    # Generate vertices of the Convex hulls for each existing colony
    for index in colonies_keys_1:

        convexhull = ConvexHull(
            colonies[index].points)  # Get convex hull model for the colony
        points = deepcopy(colonies[index].points)
        condition = np.array(
            [[True, True] if i in convexhull.vertices else [False, False]
             for i in range(len(colonies[index].points))])
        vertices = np.extract(condition, points)
        vertices = vertices.reshape(int(len(vertices) / 2), 2)
        vertices_set[
            index] = vertices  # five arrays of vertices for the convex hulls for each colony

    # Synergistic
    if relationship == 'Synergistic':

        # Check whether two colonies overlap with each other or not
        for pair in comb:

            check = separating_axis_theorem(vertices_set[pair[0]],
                                            vertices_set[pair[1]])

            if check:

                overlap_colony = pair  # tend to merge one combination of two colonies
                break

            else:

                pass

        # EXIT. Return when no colonies overlap
        if overlap_colony == list():

            check_strength(step, colonies)

            return inner_step

        else:

            colonies[overlap_colony[0]].merge(colonies[overlap_colony[1]])
            del colonies[overlap_colony[1]]

        inner_step = overlap(step, colonies, relationship, inner_step)

        return inner_step

    else:  # Competitive

        # Check whether two colonies overlap with each other or not
        for pair in comb:

            check = separating_axis_theorem(vertices_set[pair[0]],
                                            vertices_set[pair[1]])

            if check:

                overlap_colony.append(pair)  # Two colonies will fight

        # Return when no colonies overlap
        if overlap_colony == list():

            check_strength(step, colonies)

            return inner_step

        else:

            inner_step = fight(step, colonies, overlap_colony, inner_step)

    inner_step = overlap(step, colonies, relationship, inner_step)

    return inner_step
示例#18
0
time.sleep(x + 2)
print("");print('> Вы выходите из класса')
time.sleep(x + 1.8)
print("");print("> Новый квест : [Сходи покури!]")
time.sleep(x + 1.8)
print("");print("...")
time.sleep(x + 1.65)
print("");print('> Вас окликивает малышня, кажется они хотят драться')
while True:
    if done == 1:
        break
    if quest_smoked == False:
        answer = input(Fore.GREEN + "Что делать(Уйти/Драться/Покурить): ")
        if answer == "Драться":
            hero = 1
            money += fight.fight(level,hp_max,hp_current,dmg,defen,hero)
            while True:
                if done == 1:
                    break
                answer = input(Fore.GREEN + "Что делать(Уйти/Покурить): ")
                if answer == "Покурить":
                    time.sleep(x + 1.5)
                    print("");print("...")
                    time.sleep(x + 1.5)
                    print("");print(Fore.GREEN + '> Вы пошли курить')
                    time.sleep(x + 1.5)
                    print("");print("...")
                    time.sleep(x + 1.5)
                    print(""); print(Fore.GREEN + "> Подходит Захар и просит сигарету")
                    while True:
                        if done == 1:
示例#19
0
    elif len(cmd) == 1:
        cmd = "".join(cmd)
        if cmd == "q" or cmd == "quit":
            print("\nFarewell...\n")
            break
        elif cmd == "i" or cmd == "inventory":
            player.look_in_bag()
        elif cmd == "inspect":
            player.inspect_room()
        elif cmd == "m" or cmd == "map":
            player.map()
        elif cmd == 'navi':
            print(images['navi'])
        elif cmd == 's' or cmd == "stats":
            print(player)
        elif cmd == 'fight':
            if player.location.enemy:
                fight(player.location.enemy)
            else:
                print("\nFight what? There's nobody else here.")
        else:
            print("\nHey! Invalid command, try something else.\n")

    # Catch empty or longer commands
    else:
        print("\nHey! Invalid command, try something else.\n")
    # Await new command after previous output
    cmd = input(
        f"\nWhat do you do, {player.name}?\n(Listen! Type 'navi' to see a list of commands.)\n"
    ).split(' ')
示例#20
0
# 请写一个小游戏,人狗大站;  规则:
#     1 2个角色,人和狗,游戏开始后,生成2个人,3条狗,人狗互相交替对战(注意,人只能打狗,  狗也只会咬人);
#         人的打击力为10;  初始化血为100;    狗的攻击力为 15; 初始化血为80;
#     2  人被狗咬了会掉血,狗被人打了也掉血,狗和人的攻击力,具备的功能都不一样。血为0的话,表示死亡,退出游戏;
#         人和狗的攻击力,都会因为被咬, 或者被打而降低(人被咬一次,打击力降低2;  狗被打一次,攻击力降低3);
#     3   对战规则:
#      A  随机决定,谁先开始攻击;
#      B  一方攻击完毕后, 另外一方再开始攻击;  攻击的目标是随机的(比如, 人要打狗了, 随机找一条血不为0的狗攻击);
#      C  每次攻击, 双方只能安排一个人,或者一条狗进行攻击;
# 提示:注意组织代码的方式;狗类用一个单独的py文件;
# 人用一个单独的py文件; 在写一个fight模块(也用类来组织;在这个模块中,导入人和狗模块中编写好的方法)
from dogs import dog
from people import person
from fight import fight

print('-' * 10)
print('游戏开始')
person1 = person(100, 10)
person2 = person(100, 10)
dog1 = dog(80, 15)
dog2 = dog(80, 15)
dog3 = dog(80, 15)
f = fight([dog1, dog2, dog3], [person1, person2])
f.beat()
示例#21
0
    def enter(self,last_room):
#显示房间剧情
        print "---------------------------------------------\n"
        num = re.findall(r"\d",self.room_name)
        if num == []:
            if self.room_name == "palace":
                print u"宫殿"
            else:
                print u"地下室"
        else:
            print u"进入房间%s" % num[0]
        print self.words

#获取玩家在房间的位置
        self.player_pos = self.get_playerpos(last_room)
#显示房间样子
        display.display_room(self.player_pos,self.monster,self.monster_pos,
        self.door_pos,self.goods)
#如果去过地下室,则可以进入宫殿
        if self.room_name == "basement":
            Room.open_flag = 1
#进入玩家选择循环
        while True:
            print u"请选择:1、搜索物品  2、消灭怪物  3、离开房间"
            print u"Q键查看玩家属性  E键显示小地图"
            choose0 = raw_input('>')
            if choose0 == "q":
                display.display_property(self.monster)
            elif choose0 == "e":
                display.display_pos(self.room_name)
            elif choose0 == "1":
                fight.find_goods(self.goods)
                self.goods = []
            elif choose0 == "2":
                print u"请选择你要挑战的怪物:W、上 S、下 A、左 D、右  F、中  R、返回"
                choose1 = raw_input('>')
                if choose1 == "r":
                    continue
                monster_toward = Room.toward_dict.get(choose1)
                if monster_toward not in self.monster_pos:
                    print u"那里没有怪物。"
                    continue
                fight.fight(self.monster)
                self.monster_pos.remove(monster_toward)
            elif choose0 == "3":
                print u"请选择你要进入的房间:W、上 S、下 A、左 D、右    R、返回"
                choose2 = raw_input('>')
                if choose2 == "r":
                    continue
                door_toward = Room.toward_dict.get(choose2)
                if door_toward not in self.door_pos:
                    print u"那是一堵墙。"
                    continue
                if door_toward in self.monster_pos:
                    print u"你必须打败门前的怪物,才能进去。"
                    continue
                #根据方向得到下个房间的名字
                num_dict = {"up":-3,"down":3,
                               "left":-1,"right":1}
                next_roomnum = Room.room_dict.get(self.room_name)
                next_roomnum += num_dict.get(door_toward)
                for key,value in Room.room_dict.items():
                    if value == next_roomnum:
                        next_room =  key
                        break
                if next_room == "palace" and Room.open_flag == 0:
                    print u"这个地方感觉很危险,我还是等会再进去吧~"
                    continue
                return next_room
            else:
                print u"指令错误。"
示例#22
0
def move(board, y, x, exit_y, exit_x):
    live = 100  # dorobic import
    statistic = {
        "atak": 10,
        "obrona": 3,
        "wiedza": 5,
        "ww": 55
    }  # dorobic import
    enemy = {"atak": 3, "obrona": 3, "wiedza": 5, "ww": 35}  # import?
    time_start = timechecker()  # przeniesc do maina
    player = '\033[1;34m@\033[1;m'
    board[y][x] = player
    old_player = "."
    print_board(board, live, statistic)
    while board[exit_y][exit_x] != player:
        move = getch()
        if move == "q":
            exit()
        if move == "w":
            y -= 1
            if board[y][x] != "." and board[y][x] != "T":
                print("Auc! Nabiles sobie guza!")
                y += 1
            elif board[y][x] == "T":
                fight.fight(live, statistic, 20, enemy)
                board[y][x] = player
                board[y + 1][x] = old_player
                print_board(board, live, statistic)
            else:
                board[y][x] = player
                board[y + 1][x] = old_player
                print_board(board, live, statistic)
        if move == "s":
            y += 1
            if board[y][x] != "." and board[y][x] != "T":
                print("Auc! Nabiles sobie guza!")
                y -= 1
            elif board[y][x] == "T":
                fight.fight(live, statistic, 20, enemy)
                board[y][x] = player
                board[y - 1][x] = old_player
                print_board(board, live, statistic)
            else:
                board[y][x] = player
                board[y - 1][x] = old_player
                print_board(board, live, statistic)

        if move == "a":
            x -= 1
            if board[y][x] != "." and board[y][x] != "T":
                print("Auc! Nabiles sobie guza!")
                x += 1
            elif board[y][x] == "T":
                fight.fight(live, statistic, 20, enemy)
                board[y][x] = player
                board[y][x + 1] = old_player
                print_board(board, live, statistic)
            else:
                board[y][x] = player
                board[y][x + 1] = old_player
                print_board(board, live, statistic)

        if move == "d":
            x += 1
            if board[y][x] != "." and board[y][x] != "T":
                print("Auc! Nabiles sobie guza!")
                x -= 1
            elif board[y][x] == "T":
                fight.fight(live, statistic, 20, enemy)
                board[y][x] = player
                board[y][x - 1] = old_player
                print_board(board, live, statistic, inventory)
            else:
                board[y][x] = player
                board[y][x - 1] = old_player
                print_board(board, live, statistic)

    print("Brawo! Przeszedles do nastepnego etapu!")
    time_stop = timechecker()
    player_time = time_stop - time_start
    player_time = str(player_time)
    print("Twoj czas to:" + player_time[:7])
    time.sleep(3)
def robot_run(num,match_type,appid):
    fight.fight(num,match_type,appid)
    sys.exit(0)
示例#24
0
    immune_to = int(line[6])
    i = 7
    if immune_to == 0:
        immune_set = set()
    else:
        immune_set = set()
        for j in range(immune_to):
            immune_set |= {line[i + j]}
        i += immune_to

    weak_to = int(line[i])
    i += 1
    if weak_to == 0:
        weak_set = set()
    else:
        weak_set = set()
        for j in range(weak_to):
            weak_set |= {line[i + j]}

    group = Group(spec, n, health, initiative, damage, dmg_type, immune_set,
                  weak_set)
    groups |= {group}

groups = list(groups)
groups.sort()
fight(deepcopy(groups), 1)
# will run a bit more slowly if a large number of simulations is needed, or if the input is large, perhaps
# worst if both
fight(groups, 2)
示例#25
0
def map3_action(char_alloved, board, x, y):
    print(x, y)
    board, x, y, button = get_action(char_alloved, board, x, y, "maps/map3.txt")
    inv = change_files.import_inventory('test_inventory.csv')
    stats = change_files.import_stats('stats.csv')
    change_files.level_up(stats['Exp'], stats['Level'])

    if board[y][x] == '~':
        if 'bucket' in inv:
            material = ['material']
            change_files.add_to_inventory(inv, material)
            print('+1 material')
            sleep(0.5)
            board[y][x] = ','

    if board[y][x] == '⚗':
        x, y = back(button, x, y)
        board_change('maps/map3.txt', x, y)

        if 'bucket' not in inv and 'robe' not in inv:
            print('Im a local tailor. If you want me to make something for you, you have to take some materials for me! On the west you can find cotton field. Please bring to me some cotton!')
            sleep(1)
            bucket = ['bucket']
            change_files.add_to_inventory(inv, bucket)

        elif 'bucket'in inv and 'material' not in inv:
            print('Cotton field is on the west.')
            sleep(0.5)

        elif 'bucket'in inv and inv['material'] < 5:
            print('Its not enough')
            sleep(0.5)

        elif 'bucket' in inv and inv['material'] == 5:
            print('You did it!')
            sleep(0.5)
            del inv['material']
            del inv['bucket']
            robe = ['robe']
            change_files.add_to_inventory(inv, robe)
            change_files.add_to_stats(stats, 0, 10, 0, 2, 80, 0)

        elif 'robe' in inv:
            print('With this robe even those brain-dead knights wont notice you arent from town!')
            sleep(0.5)

    if board[y][x] == char_alloved[11]:
        print('Come on, little bitch!')
        sleep(0.5)
        enemy_health = fight.fight(50, 50, 10, 10, 50, x, y)
        if enemy_health <= 0:
            board[y][x] = '&'
            board_change('maps/map3.txt', x, y)
            print('enemy is beaten \n plus 75XP')
            sleep(0.5)
        x, y = back(button, x, y)
        board_change('maps/map3.txt', x, y)

    if board[y][x] == '&':
        x, y = back(button, x, y)
        board_change('maps/map3.txt', x, y)
        print('Enough for me...')
        sleep(0.5)

    if board[y][x] == '⍑':
        x, y = back(button, x, y)
        board_change('maps/map3.txt', x, y)
        print('This is FIGHT CLUB. Here you can fight with great oponnents to improve your battling skills!')
        sleep(0.5)

    if board[y][x] == '⯂':
        if 'robe' not in inv:
            x, y = back(button, x, y)
            board_change('maps/map3.txt', x, y)
            print('What are you looking for, beggar? Get the f**k off!')
            sleep(0.5)
        elif 'robe' in inv:
            print('You are welcome, my lord.')
            board[y][x] = " "
            sleep(0.5)

    if board[y][x] == char_alloved[13] or board[y][x] == char_alloved[14]:
        stats['Health'] = stats['Max health']
        change_files.add_to_stats(stats, 0, 0, 0, 0, 0, 0)
        print('Full health')
        sleep(0.2)

    if board[y][x] == 'x':
        if "robe" not in inv:
            x, y = back(button, x, y)
            board_change('maps/map3.txt', x, y)
            print('What are you looking for, beggar? Get the f**k off!')
            sleep(0.5)
        elif "robe" in inv:
            board[y][x] = " "

    if board[y][x] == char_alloved[10]:
        return 4, x, y
    else:
        return 3, x, y
示例#26
0
文件: shop.py 项目: LeonP92/GTM
def showshop(toShow):
	possible = 0
	money = int(game.parse("Money"))
	itemCost = 0
	if toShow==0:
		f = open("items.txt", "r")
		data = f.read()
		print(fight.hilight("\nWelcome to the weapon shop!",'33',1) + fight.hilight(" BETTER NOT STEAL ANYTHING...", '31',1))
		print data
		f.close()
	userinput = raw_input("What do you need from me??" +fight.hilight(" [Hint: Type in what you want, you can also type 'steal [item name]' but be prepared to fight the shop keeper! Also hit Q to quit and I for character info]\n",'33',1)).lower()
	for item in items:
		if possible == 0:
			if userinput == item.lower(): #item match without stealing
					possible = 2
			elif userinput.split()[0] == 'steal': #If first word was steal... then possible = 2
					possible = 1
					stealing = userinput.split()[1]
			elif userinput == "q":# to leave
				possible = 3
			elif userinput =="i":# to see info
				possible = 4
		else:
			break;
		itemCost = itemCost+1
	if possible == 0:
		print("What was that? I couldn't understand you.... Try again or leave...")
		showshop(1)
	elif possible == 1: #shop keeper fight
		print fight.hilight("HEY... HEY PUNK, TRYING TO STEAL STUFF? WELL I HOPE YOU CAN FIGHT!",'31',1)
		time.sleep(2)
		fight.fight("shop", int(game.parse("Level"))*170, int(game.parse("Level"))*220)
		canSteal = checkItem(stealing)
		# if you did stole something
		if canSteal == 0:
			print(fight.hilight("NICE WORK MAN! You just stole a "+stealing,'32',1))
			game.changeAttr(4,stealing)
		else: 
			print(fight.hilight("Home slice... you just beat up the poor sucker for no reason. You got this item", '33', 1))
		print(fight.hilight("You: Woops... I guess I went too hard on the fool! Better run!", '36', 1))
		time.sleep(2)
	elif possible == 3:
		print("Alright... come again soon!")
	elif possible == 4:
		game.displayfile("character.txt")
		showshop(1)
	else:
		# see if you can buy an item
		if money >= (itemCost*300) :
			canBuy = checkItem(userinput)
			if canBuy == 0: # can buy
				game.changeAttr(3, str(money - (itemCost*300)))
				game.changeAttr(4, items[itemCost-1])
				print("\nItem Purchased! You bought: " + items[itemCost-1] +". You now have: $" + game.parse("Money"))
			else:
				print(fight.hilight("Man you have that item! You don't want it again!",'31',1))
			print("Can I do anything else for ya?")
		# if the user doesn't have enough money to buy the item
		else:
			print("\nHey That item costs: " + str(itemCost*300) + "!")
			print("You don't have enough money for that punk! You trying to pull a quick one on me???? EHH???")
		showshop(1)
示例#27
0
def map4_action(char_alloved, board, x, y):
    print(x, y)
    board, x, y, button = get_action(char_alloved, board, x, y, "maps/map4.txt")
    inv = change_files.import_inventory('test_inventory.csv')
    stats = change_files.import_stats('stats.csv')
    change_files.level_up(stats['Exp'], stats['Level'])

    if board[y][x] == '⚗':
        x, y = back(button, x, y)
        board_change('maps/map4.txt', x, y)

        if 'coin' not in inv and 'permit' not in inv:
            print('I dont have time for you now!!! Help my soldiers in rescuing our town from barbarians if u want this stupid conduct pass!')
            sleep(1)
            coin = ['coin']*120
            change_files.add_to_inventory(inv, coin)

        elif 'coin'in inv and 'bandit head' not in inv:
            print('They are dying there! Just go!!!')
            sleep(0.5)

        elif 'coin'in inv and inv['bandit head'] < 4:
            print('This is not all of them yet!')
            sleep(0.5)

        elif 'coin' in inv and inv['bandit head'] == 4:
            print('Thank you for your help. Here is your conduct pass.')
            sleep(1)
            del inv['bandit head']
            del inv['coin']
            permit = ['permit']
            change_files.add_to_inventory(inv, permit)
            change_files.add_to_stats(stats, 0, 0, 0, 0, 250, 0)

        elif 'permit' in inv:
            print("I have no time, bye!")
            sleep(0.5)

    if board[y][x] == char_alloved[11]:
        print('F**k you!!!')
        sleep(0.5)
        enemy_health = fight.fight(75, 75, 13, 13, 75, x, y)
        if enemy_health <= 0:
            board[y][x] = '&'
            board_change('maps/map4.txt', x, y)
            print('enemy is beaten \n plus 75XP')
            sleep(0.5)
            bandit_head = ['bandit head']
            change_files.add_to_inventory(inv, bandit_head)
            print('+1 bandit head')
            sleep(0.25)
        x, y = back(button, x, y)
        board_change('maps/map4.txt', x, y)

    if board[y][x] == '&':
        x, y = back(button, x, y)
        board_change('maps/map4.txt', x, y)
        print('Dead body.')
        sleep(0.5)

    if board[y][x] == '⯂':
        if 'permit' not in inv:
            x, y = back(button, x, y)
            board_change('maps/map4.txt', x, y)
            print('You need conduct pass to meet the king.')
            sleep(0.5)
        elif 'permit' in inv:
            board[y][x] = " "
            print('King is waiting for you, my lord. Better hurry.')
            sleep(0.5)

    if board[y][x] == 'x':
        if "permit" not in inv:
            x, y = back(button, x, y)
            board_change('maps/map4.txt', x, y)
            print('You need conduct pass to meet the king.')
            sleep(0.5)
        elif "permit" in inv:
            board[y][x] = " "
            print('King is waiting for you, my lord. Better hurry.')
            sleep(0.5)

    if board[y][x] == char_alloved[13] or board[y][x] == char_alloved[14]:
        stats['Health'] = stats['Max health']
        change_files.add_to_stats(stats, 0, 0, 0, 0, 0, 0)
        print('Full heal')
        sleep(0.2)

    if board[y][x] == char_alloved[10]:
        return 5, x, y
    else:
        return 4, x, y
    def choose_do(self, lastroom):

        #根据上个房间的号码和当前房间号码的差得到当前玩家在房间里的位置
        compare = lastroom - self.roomnum
        if compare == -3:
            self.player_pos = "up"
        elif compare == -1:
            self.player_pos = "left"
        elif compare == 1:
            self.player_pos = "right"
        elif compare == 3:
            self.player_pos = "down"
        else:
            pass

        #显示房间场景
        display.display_room(self.player_pos, self.monster, self.monster_pos,
                             self.door_pos, self.goods)

        while True:
            print u"你可以选择:1、搜索房间  2、离开房间  3、查看小地图  4、查看自己的属性 5、消灭怪物"
            choice = raw_input(">")
            if choice == '1':
                if self.goods != []:
                    print self.word
                    fight.use_goods(self.goods)
                    self.goods = []
                else:
                    print u"\t什么也没有!\n"
            elif choice == '2':
                while True:
                    print u"请选择你要进入的房间:W:上 A:左 S:下 D:右 Q:返回"
                    choose_room = raw_input('>')

                    if choose_room == "w":
                        choose_room = "up"
                    elif choose_room == "a":
                        choose_room = "left"
                    elif choose_room == "s":
                        choose_room = "down"
                    elif choose_room == "d":
                        choose_room = "right"
                    elif choose_room == 'q':
                        break
                    else:
                        pass

                    if choose_room not in self.door_pos:
                        print u"选择错误!"
                    else:
                        if choose_room in self.monster_pos:
                            print u"你必须打败门口的守卫,才能进入这个房间!"
                        else:
                            if choose_room == "up":
                                return self.roomnum - 3
                            elif choose_room == "left":
                                return self.roomnum - 1
                            elif choose_room == "down":
                                return self.roomnum + 3
                            elif choose_room == "right":
                                return self.roomnum + 1
                            else:
                                pass
            elif choice == '3':
                display.display_pos(self.roomnum)
            elif choice == '4':
                display.display_property(self.monster)
            elif choice == '5':
                if self.monster_pos == []:
                    print u"没有怪物!"
                else:
                    print u"请选择你要攻击的怪物:W:上 A:左 S:下 D:右  E:中 Q:返回"
                    choose_monster = raw_input('>')

                    if choose_monster == "w":
                        choose_monster = "up"
                    elif choose_monster == "a":
                        choose_monster = "left"
                    elif choose_monster == "s":
                        choose_monster = "down"
                    elif choose_monster == "d":
                        choose_monster = "right"
                    elif choose_monster == "e":
                        choose_monster = "middle"
                    elif choose_monster == 'q':
                        continue
                    else:
                        pass
                    if choose_monster not in self.monster_pos:
                        print u"这个地方没有怪物!"
                        continue
                    fight.fight(self.monster)
                    self.monster_pos.remove(choose_monster)
            else:
                print u"输入错误!"