コード例 #1
0
ファイル: death_defenition.py プロジェクト: yegorf1/RogueBot
def death(self, reply, reason=None):
	if self.state == 'room':
		room = roomloader.load_room(self.room[1], self.room[0], self)
		room.on_death(self, reply)
		reply(locale_manager.get('DEATH_PLACE').format(room.name))

	self.dead = True
	self.state = ''

	self.update_leaderbord(reason)
	track_stats = {
		'uid': self.uid, 
		'reason': reason, 
		'rooms_count': self.rooms_count,
		'gold': self.gold,
		'kills_count': self.monsters_killed,
		'damage': self.get_damage(),
		'defence': self.get_defence(),
		'charisma': self.get_charisma(),
		'mana_damage': self.get_mana_damage(),
		'live_time': self.get_live_time()
	}
	statistics.track(self.uid, track_stats, 'Death')

	reply(locale_manager.get('DEAD_MESSAGE').format(self.monsters_killed, self.rooms_count), [ '/start' ])

	if 'save' in self.variables:
		self.recover(reply)
コード例 #2
0
def death(self, reply, reason=None):
    if self.state == 'room':
        room = roomloader.load_room(self.room[1], self.room[0], self)
        room.on_death(self, reply)
        reply(locale_manager.get('DEATH_PLACE').format(room.name))

    self.dead = True
    self.state = ''

    self.update_leaderbord(reason)
    track_stats = {
        'uid': self.uid,
        'reason': reason,
        'rooms_count': self.rooms_count,
        'gold': self.gold,
        'kills_count': self.monsters_killed,
        'damage': self.get_damage(),
        'defence': self.get_defence(),
        'charisma': self.get_charisma(),
        'mana_damage': self.get_mana_damage(),
        'live_time': self.get_live_time()
    }
    statistics.track(self.uid, track_stats, 'Death')

    reply(
        locale_manager.get('DEAD_MESSAGE').format(self.monsters_killed,
                                                  self.rooms_count),
        ['/start'])

    if 'save' in self.variables:
        self.recover(reply)
コード例 #3
0
def won(self, reply, tornament=False, boss=None):
	room = roomloader.load_room(self.room[1], self.room[0], self)

	if room.code_name == 'tornament' and tornament:
		reply('Стоп. Это же турнир, тут все работает не так. Ты просто нанес огромный урон противникам. Примерно `100`')
		room.make_damage(self, reply, 100)
		return

	self.monsters_killed += 1
	room.on_won(self, reply)

	items = [ itemloader.load_item(i, 'loot') for i in room.loot ]
	loot = ', '.join([ item.name for item in items ]) if len(items) > 0 else 'Ничего.'

	for lt in room.loot:
		self.add_item('loot', lt)

	if room.room_type == 'boss' and boss is not None:
		total_damage = self.get_room_temp('user_damage', def_val=0)

		if total_damage >= 1:
			room.coins = round(total_damage / boss['max_hp'] * boss['coins'])

		else:
			room.coins = 0

	if room.coins > 0:
		reply(locale_manager.get('GOLD_FOUND').format(room.coins))

		self.give_gold(room.coins)

	reply(locale_manager.get('YOU_WON').format(loot))

	if room.room_type != 'boss':
		self.leave(reply)
コード例 #4
0
ファイル: gods_defenition.py プロジェクト: yegorf1/RogueBot
def divine_intervention(self, reply):
	res = random.random()

	try:
		if (datetime.now() - self.last_message).total_seconds() > 60 * 60 * 2:
			return
	except:
		self.last_message = datetime.now()

	if self.dead:
		return

	if self.has_item('intoxicated_shoes'):
		reply(locale_manager.get('DIVINE_FORGIVES'))
		self.remove_item('intoxicated_shoes')
	else:
		if res < 0.1 and not self.has_item('assasin_ticket'):
			self.add_item('special', 'assasin_ticket')
			reply(locale_manager.get('DIVINE_ASSASIN'))
		elif res < 0.55 and self.hp < self.max_hp:
			self.heal(self.max_hp // 2)
			reply(locale_manager.get('DIVINE_HEAL'))
		elif self.mp < self.max_mp:
			self.mana(self.max_mp // 2)
			reply(locale_manager.get('DIVINE_MANA'))
		else:
			self.give_gold(2000)
コード例 #5
0
    def open_room(self, reply, room_type=None, room_name=None):
        self.state = 'room'

        if not (room_type and room_name):
            if self.rooms_to_story < 1:
                room_type, room_name = 'story', self.next_story_room
            else:
                self.rooms_to_story -= 1
                room_type, room_name = roomloader.get_next_room()

        self.room = (room_type, room_name)
        self.room_temp = {}

        room = roomloader.load_room(self.room[1], self.room[0])

        if room_type == 'story':
            self.story_level += 1
            self.next_story_room = room.next_story_room

            mn, mx = room.next_story_room_range
            self.rooms_to_story = random.randint(mn, mx)

        for i in self.get_items():
            i.on_room(self, reply, room)

        if room.room_type == 'monster':
            self.set_room_temp('hp', room.hp)

        reply(locale_manager.get('ROOM_OPENED'))
        reply(room.name + '!')

        room.enter(self, reply)

        if self.state == 'room':
            reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
コード例 #6
0
def open_shop(self, reply):
    self.state = 'shop'

    if self.visited_shop:
        self.open_corridor(reply)
        return

    if self.shop_names is None or len(self.shop_items) != 4:
        self.shop_items = itemloader.load_shop_items()

    items = [
        itemloader.load_item(i[1], i[0], usr=self) for i in self.shop_items
    ]
    self.shop_names = [i.name for i in items]

    for item in self.get_items():
        item.on_shop(self, reply, items)

    txt = locale_manager.get('SHOP_MESSAGE').format(
        items[0].name, items[0].price, items[0].description, items[1].name,
        items[1].price, items[1].description, items[2].name, items[2].price,
        items[2].description, items[3].name, items[3].price,
        items[3].description)

    keyboard = [
        self.shop_names[0:2], self.shop_names[2:],
        locale_manager.get('EXIT')
    ]

    reply(txt, keyboard)
コード例 #7
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def divine_intervention(self, reply):
        res = random.random()

        try:
            if (datetime.now() -
                    self.last_message).total_seconds() > 60 * 60 * 2:
                return
        except:
            self.last_message = datetime.now()

        if self.dead:
            return

        if self.has_item('intoxicated_shoes'):
            reply(locale_manager.get('DIVINE_FORGIVES'))
            self.remove_item('intoxicated_shoes')
        else:
            if res < 0.1 and not self.has_item('assasin_ticket'):
                self.add_item('special', 'assasin_ticket')
                reply(locale_manager.get('DIVINE_ASSASIN'))
            elif res < 0.55 and self.hp < self.max_hp:
                self.heal(self.max_hp // 2)
                reply(locale_manager.get('DIVINE_HEAL'))
            elif self.mp < self.max_mp:
                self.mana(self.max_mp // 2)
                reply(locale_manager.get('DIVINE_MANA'))
            else:
                self.gold += 2000
コード例 #8
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def prayto(self, reply, god):
        god_num = -1

        if god == self.gods[BUDDHA_NUM]:  # Buddha
            reply(locale_manager.get('BUDDHA_PRAYED'))
            god_num = BUDDHA_NUM
        elif god == self.gods[JESUS_NUM]:  # Jesus
            reply(locale_manager.get('JESUS_PRAYED'))
            god_num = JESUS_NUM
        elif god == self.gods[ALLAH_NUM]:  # Allah
            reply(locale_manager.get('ALLAH_PRAYED'))
            god_num = ALLAH_NUM
        elif god == self.gods[AUTHOR_NUM]:  # Author
            reply(locale_manager.get('AUTHOR_PRAYED'))
            god_num = AUTHOR_NUM
        else:
            reply(locale_manager.get('NO_GOD'))

        if god_num >= 0:
            self.gods_level[god_num] += 1

            for item in self.get_items():
                item.on_pray(self, reply, god_num)

            if self.gods_level[god_num] >= GOD_LEVEL:
                self.god_love(reply, god_num)

        if self.state == 'pray':
            self.prayed = True
            self.open_corridor(reply)
コード例 #9
0
ファイル: fight_defenition.py プロジェクト: yegorf1/RogueBot
def won(self, reply, tornament=False, boss=None):
	room = roomloader.load_room(self.room[1], self.room[0], self)

	if room.code_name == 'tornament' and tornament:
		reply('Стоп. Это же турнир, тут все работает не так. Ты просто нанес огромный урон противникам. Примерно `100`')
		room.make_damage(self, reply, 100)
		return

	self.monsters_killed += 1
	room.on_won(self, reply)

	items = [ itemloader.load_item(i, 'loot') for i in room.loot ]
	loot = ', '.join([ item.name for item in items ]) if len(items) > 0 else 'Ничего.'

	for lt in room.loot:
		self.add_item('loot', lt)

	if room.room_type == 'boss' and boss is not None:
		total_damage = self.get_room_temp('user_damage', def_val=0)

		if total_damage >= 1:
			room.coins = round(total_damage / boss['max_hp'] * boss['coins'])

		else:
			room.coins = 0

	if room.coins > 0:
		reply(locale_manager.get('GOLD_FOUND').format(room.coins))

		self.give_gold(room.coins)

	reply(locale_manager.get('YOU_WON').format(loot))

	if room.room_type != 'boss':
		self.leave(reply)
コード例 #10
0
ファイル: shop_defenition.py プロジェクト: yegorf1/RogueBot
def open_shop(self, reply):
	self.state = 'shop'

	if self.visited_shop:
		self.open_corridor(reply)
		return

	if self.shop_names is None or len(self.shop_items) != 4:
		self.shop_items = itemloader.load_shop_items()

	items =  [ itemloader.load_item(i[1], i[0], usr=self) for i in self.shop_items ]
	self.shop_names = [ i.name for i in items ]

	for item in self.get_items():
		item.on_shop(self, reply, items)

	txt = locale_manager.get('SHOP_MESSAGE').format(
		items[0].name, items[0].price, items[0].description, 
		items[1].name, items[1].price, items[1].description,
		items[2].name, items[2].price, items[2].description,
		items[3].name, items[3].price, items[3].description
	)

	keyboard = [ self.shop_names[0:2], self.shop_names[2:], locale_manager.get('EXIT') ]

	reply(txt, keyboard)
コード例 #11
0
ファイル: room_defenition.py プロジェクト: KaneNOD/RogueBot
def open_room(self, reply, room_type=None, room_name=None):
    if self.race == RAT_RACE:
        reply('Ты — крыса, у тебя не хватило сил сдвинуть дверь с места :(')
        self.open_corridor(reply)
        return

    self.state = 'room'

    self.rooms_count += 1
    for m in self.missions:
        m.room_opened()

    if not (room_type and room_name):
        room_type, room_name = roomloader.get_next_room(self)

    logger.info('room_opened ' + room_name)

    last_mission = self.get_last_mission()
    if last_mission.get_room_type(
    ) == room_type and last_mission.get_room_name() == room_name:
        self.pop_mission()

    self.room = (room_type, room_name)
    self.room_temp = {}

    room = roomloader.load_room(self.room[1], self.room[0])

    for i in self.get_items():
        i.on_room(self, reply, room)

    to_delete = []
    for i, b in enumerate(self.buffs):
        try:
            b.on_room(self, reply, room)
            if b.time <= 0:
                to_delete.append(i)
        except:
            pass

    for i in reversed(to_delete):
        self.buffs[i].on_end(self, reply, room)
        del self.buffs[i]

    if self.pet:
        self.get_pet().on_room(self, reply, room)

    if room.room_type == 'monster':
        self.set_room_temp('hp', room.hp)

    reply(locale_manager.get('ROOM_OPENED'))
    reply(room.name + '!')

    room.enter(self, reply)

    if self.state == 'room':
        reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
コード例 #12
0
ファイル: user.py プロジェクト: satan007/RogueBot
    def __init__(self, uid):
        super(User, self).__init__()

        self.uid = uid

        self.name = 'none'
        self.hp = 100
        self.mp = 100
        self.gold = 200

        self.max_hp = 150
        self.max_mp = 150

        self.state = 'name'

        self.items = []
        self.active_items = []
        self.inventory_page = 0

        self.gods = [
            locale_manager.get('BUDDHA'),
            locale_manager.get('JESUS'),
            locale_manager.get('ALLAH'),
            locale_manager.get('AUTHOR')
        ]
        self.gods_level = [0 for g in self.gods]
        self.last_god = ''
        self.prayed = False

        self.damage = 10
        self.defence = 1
        self.charisma = 0
        self.mana_damage = 0
        self.intelligence = 0

        self.visited_shop = False
        self.shop_items = []
        self.shop_names = []

        self.tags = []

        self.room = ('', '')
        self.room_temp = {}

        self.reborn_answer = None
        self.dead = False

        self.rooms_to_story = random.randint(5, 25)
        self.next_story_room = 'first'
        self.story_level = 0

        self.last_message = datetime.now()
        self.rooms_count = 0
        self.monsters_killed = 0

        self.subject = None
コード例 #13
0
ファイル: corridor_defenition.py プロジェクト: jofg123/Rogue
def corridor(self, reply, text):
    if self.has_tag('wet'):
        self.remove_tag('wet')
    if self.has_tag('wet_enemy'):
        self.remove_tag('wet_enemy')

    if text.startswith(locale_manager.get('OPEN_NEXT_DOOR').split()[0]):
        self.open_room(reply)
    elif text == locale_manager.get('USE_SIGN'):
        self.open_room(reply, 'special', 'sign')
    elif text.startswith(locale_manager.get('PRAY_TO_GOD').split()[0]):
        self.pray(reply)
    elif text.startswith(locale_manager.get('OPEN_SHOP').split()[0]):
        self.open_shop(reply)
    elif text.startswith(locale_manager.get('SHOW_INVENTORY').split()[0]):
        self.inventory_page = 0
        self.open_inventory(reply)
    elif text.startswith(
            locale_manager.get('PLAYER_CHARACTERISTICS').split()[0]):
        self.show_characteristics(reply)
#	elif text == 'Хеллуин!' and not self.get_variable('halloween_visited', False):
#		self.open_room(reply, 'special', 'helloween_shop')
#		self.set_variable('halloween_visited', True)
    elif text == 'Умереть':
        reply('Пакеда!', photo='BQADAgAD5wgAAmrZzgcHFvPa24KvDwI')
        self.death(reply, reason='Суицид')
    elif text == locale_manager.get('JOIN_TORNAMENT'):
        self.open_room(reply, 'usual', 'cesar')
    elif self.get_prev_level() is not None and text == locale_manager.get(
            'GO_UP'):
        self.level = self.get_prev_level()
        reply(
            'Поднимаясь выше по лестнице, ты заметил, что кто-то написал, какие монстры есть на этом этаже, но не все было разборчиво..'
        )

        msg = ''
        for ind, name in enumerate(roomloader.get_level_rooms(
                self, self.level)):
            msg += '{0}. {1}\n'.format(ind + 1, name)

        reply(msg)

        self.open_corridor(reply)
    elif self.get_next_level() is not None and text == locale_manager.get(
            'GO_DOWN'):
        self.level = self.get_next_level()
        reply(
            'Спускаясь, ты заметил, что кто-то написал, какие монстры есть на этом этаже, но не все было разборчиво..'
        )

        msg = ''
        for ind, name in enumerate(roomloader.get_level_rooms(
                self, self.level)):
            msg += '{0}. {1}\n'.format(ind + 1, name)

        reply(msg)

        self.open_corridor(reply)
    else:
        self.open_corridor(reply)
コード例 #14
0
ファイル: user.py プロジェクト: NikAlexSer/RogueBot
	def death(self, reply, reason=None):
		if self.state == 'room':
			room = roomloader.load_room(self.room[1], self.room[0])
			reply(locale_manager.get('DEATH_PLACE').format(room.name))

		self.dead = True
		self.state = ''

		self.update_leaderbord(reason)

		reply(locale_manager.get('DEAD_MESSAGE').format(self.monsters_killed, self.rooms_count), [ '/start' ])
コード例 #15
0
def name_confirm(self, reply, text):
	if len(text) == 7:
		txt = locale_manager.get('NAME_CONFIRMED').format(self.name)
		self.state = 'first_msg'

		logger.info('New user with id {0}'.format(self.uid))

		reply(txt, [ locale_manager.get('WHATS_NEXT') ])
	else:
		self.state = 'name'
		reply(locale_manager.get('ASK_NAME_AGAIN'))
コード例 #16
0
ファイル: fight_defenition.py プロジェクト: jofg123/Rogue
def fight_action(self, reply, text):
    room = roomloader.load_room(self.room[1], self.room[0], self)
    if text == locale_manager.get('KICK_ARM'):
        dmg = self.get_damage() + self.get_damage_bonus(reply)

        reply(locale_manager.get('MONSTER_DAMAGED').format(dmg))

        room.make_damage(self, reply, dmg)
    elif text == locale_manager.get('KICK_MAGIC'):
        dmg = self.get_mana_damage()

        if self.use_mana(5):
            reply(locale_manager.get('MAGIC_KICKED').format(dmg))

            room.make_damage(self, reply, dmg)
        else:
            reply('Маны то не хватает :(')
    elif text.startswith(locale_manager.get('USE')):
        name = 'foo'
        item = None

        if '(' in text:
            name = text[len(locale_manager.get('USE')):]
            name = name[:name.rindex('(') - 1]

        for i in self.get_items():
            if i.name == name:
                item = i
                break

        if item:
            dmg = 0
            if item.can_use(self, reply, room):
                item.success(self, reply, room)
                dmg += item.fight_use(self, reply, room)
            else:
                item.failure(self, reply, room)

            if dmg != 0 and item.strengthoff is False:
                dmg += self.get_damage() + self.get_damage_bonus(reply)

            if item.disposable:
                self.remove_item(item.code_name)

            if self.state == 'room':
                reply(locale_manager.get('ITEM_USED').format(name, dmg))

                room.make_damage(self, reply, dmg)
        else:
            reply(locale_manager.get('NO_FIGHT_THING'))

            self.throw_dice(reply, 'noname')
    else:
        reply(locale_manager.get('DIDNT_UNDERSTAND'))

    if self.state == 'room':
        self.fight_answer(reply)
コード例 #17
0
ファイル: fight_defenition.py プロジェクト: yegorf1/RogueBot
def fight_action(self, reply, text):
	room = roomloader.load_room(self.room[1], self.room[0], self)
	if text == locale_manager.get('KICK_ARM'):
		dmg = self.get_damage() + self.get_damage_bonus(reply)

		reply(locale_manager.get('MONSTER_DAMAGED').format(dmg))

		room.make_damage(self, reply, dmg)
	elif text == locale_manager.get('KICK_MAGIC'):
		dmg = self.get_mana_damage()

		if self.use_mana(5):
			reply(locale_manager.get('MAGIC_KICKED').format(dmg))

			room.make_damage(self, reply, dmg)
		else:
			reply('Маны то не хватает :(')
	elif text.startswith(locale_manager.get('USE')):
		name = 'foo'
		item = None

		if '(' in text:
			name = text[len(locale_manager.get('USE')):]
			name = name[:name.rindex('(')-1]

		for i in self.get_items():
			if i.name == name:
				item = i
				break

		if item:
			dmg = 0
			if item.can_use(self, reply, room):
				item.success(self, reply, room)
				dmg += item.fight_use(self, reply, room)
			else:
				item.failure(self, reply, room)

			if dmg != 0 and item.strengthoff is False:
				dmg += self.get_damage() + self.get_damage_bonus(reply)

			if item.disposable:
				self.remove_item(item.code_name)

			if self.state == 'room':
				reply(locale_manager.get('ITEM_USED').format(name, dmg))

				room.make_damage(self, reply, dmg)
		else:
			reply(locale_manager.get('NO_FIGHT_THING'))

			self.throw_dice(reply, 'noname')
	else:
		reply(locale_manager.get('DIDNT_UNDERSTAND'))

	if self.state == 'room':
		self.fight_answer(reply)
コード例 #18
0
ファイル: shop_defenition.py プロジェクト: yegorf1/RogueBot
def shop(self, reply, text):
	if text == locale_manager.get('EXIT'):
		reply(locale_manager.get('SHOP_EXITED'))
		self.open_corridor(reply)
	else:
		for ind, name in enumerate(self.shop_names):
			if name == text:
				buff, name = self.shop_items[ind]
				item = itemloader.load_item(name, buff, usr=self)
				self.buy(item, reply)
				return

		reply(locale_manager.get('NO_GOODS'), [ self.shop_names[0:2], self.shop_names[2:], locale_manager.get('EXIT') ])
コード例 #19
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
 def god_love(self, reply, god):
     if god == BUDDHA_NUM:  # Buddha
         reply(locale_manager.get('BUDDHA_LOVE'))
         self.mp = self.max_mp
     elif god == JESUS_NUM:  # Jesus
         reply(locale_manager.get('JESUS_LOVE'))
         self.items.append(('special', 'wine'))
     elif god == ALLAH_NUM:  # Allah
         reply(locale_manager.get('ALLAH_LOVE'))
         self.hp = self.max_hp
     elif god == AUTHOR_NUM:  # Author
         reply(locale_manager.get('AUTHOR_LOVE'))
         self.open_room(reply, 'special', 'icecream')
コード例 #20
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def shop(self, reply, text):
        if text == locale_manager.get('EXIT'):
            reply(locale_manager.get('SHOP_EXITED'))
            self.open_corridor(reply)
        else:
            for ind, name in enumerate(self.shop_names):
                if name == text:
                    buff, name = self.shop_items[ind]
                    item = itemloader.load_item(name, buff)
                    self.buy(item, reply)
                    return

            reply(locale_manager.get('NO_GOODS'), self.shop_names)
コード例 #21
0
ファイル: meet_defenition.py プロジェクト: yegorf1/RogueBot
def name_confirm(self, reply, text):
	if len(text) == 7:
		txt = locale_manager.get('NAME_CONFIRMED').format(self.name)
		self.state = 'first_msg'

		logger.info('New user with id {0}'.format(self.uid))

		self.set_perma_variable('name', text)

		reply(txt, [ locale_manager.get('WHATS_NEXT') ])
	else:
		self.state = 'name'
		reply(locale_manager.get('ASK_NAME_AGAIN'))
コード例 #22
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def get_fight_actions(self):
        actions = [
            locale_manager.get('KICK_ARM'),
            locale_manager.get('KICK_MAGIC'),
            locale_manager.get('USE') + locale_manager.get('IMAGINATION')
        ]

        for i in self.get_items():
            if i.fightable:
                act = locale_manager.get('USE') + i.name
                if act not in actions:
                    actions.append(act)

        return actions
コード例 #23
0
 def corridor(self, reply, text):
     if text.startswith(locale_manager.get('OPEN_NEXT_DOOR').split()[0]):
         self.open_room(reply)
     elif text.startswith(locale_manager.get('PRAY_TO_GOD').split()[0]):
         self.pray(reply)
     elif text.startswith(locale_manager.get('OPEN_SHOP').split()[0]):
         self.open_shop(reply)
     elif text.startswith(locale_manager.get('SHOW_INVENTORY').split()[0]):
         self.inventory_page = 0
         self.open_inventory(reply)
     elif text.startswith(
             locale_manager.get('PLAYER_CHARACTERISTICS').split()[0]):
         self.show_characteristics(reply)
     else:
         self.open_corridor(reply)
コード例 #24
0
ファイル: room_defenition.py プロジェクト: yegorf1/RogueBot
def dice(self, reply, text):
	if text == locale_manager.get('THOW_DICE'):
		self.state = 'room'

		res = sum(random.randint(1, 8) for n in range(0, DICE_MAX // 8))
		res += self.get_dice_bonus(reply)
		reply(locale_manager.get('DICE_RESULT').format(res))
		
		room = roomloader.load_room(self.room[1], self.room[0], self)
		room.dice(self, reply, res, self.subject)

		if self.state == 'room':
			reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
	else:
		reply(locale_manager.get('DICE_CONFIDENCE'), [locale_manager.get('THOW_DICE')])
コード例 #25
0
ファイル: user.py プロジェクト: NikAlexSer/RogueBot
	def dice(self, reply, text):
		if text == locale_manager.get('THOW_DICE'):
			self.state = 'room'

			res = random.randint(1, DICE_MAX)
			res += self.get_dice_bonus(reply)
			reply(locale_manager.get('DICE_RESULT').format(res))
			
			room = roomloader.load_room(self.room[1], self.room[0])
			room.dice(self, reply, res, self.subject)

			if self.state == 'room':
				reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
		else:
			reply(locale_manager.get('DICE_CONFIDENCE'), [locale_manager.get('THOW_DICE')])
コード例 #26
0
ファイル: gods_defenition.py プロジェクト: yegorf1/RogueBot
def god_love(self, reply, god):
	if god == BUDDHA_NUM: # Buddha
		reply(locale_manager.get('BUDDHA_LOVE'))
		self.mp = self.max_mp
	elif god == JESUS_NUM: # Jesus
		reply(locale_manager.get('JESUS_LOVE'))
		self.add_item('special', 'wine')
	elif god == ALLAH_NUM: # Allah
		reply(locale_manager.get('ALLAH_LOVE'))
		self.hp = self.max_hp
	elif god == AUTHOR_NUM: # Author
		reply(locale_manager.get('AUTHOR_LOVE'))
		self.open_room(reply, 'special', 'icecream')
	elif god == EMPEROR_NUM: # Emperor
		reply(locale_manager.get('EMPEROR_LOVE'))
		self.new_buff(EmperorDefence())	
コード例 #27
0
ファイル: fight_defenition.py プロジェクト: yegorf1/RogueBot
def get_fight_actions(self):
	actions = [
		locale_manager.get('KICK_ARM'),
		locale_manager.get('KICK_MAGIC'),
		locale_manager.get('USE') + locale_manager.get('IMAGINATION')
	]

	items = self.get_items()
	counter_items = Counter(items)
	for i, cnt in counter_items.most_common():
		if i.fightable:
			act = locale_manager.get('USE') + i.name + ' ({0} шт.)'.format(cnt)
			if act not in actions:
				actions.append(act)

	return actions
コード例 #28
0
    def show_characteristics(self, reply):
        msg = locale_manager.get('CHARACTERISTICS').format(
            self.get_damage(), self.get_defence(), self.get_charisma(),
            self.get_mana_damage(), self.get_intelligence())

        reply(msg)
        self.open_corridor(reply)
コード例 #29
0
ファイル: fight_defenition.py プロジェクト: jofg123/Rogue
def get_fight_actions(self):
    actions = [
        locale_manager.get('KICK_ARM'),
        locale_manager.get('KICK_MAGIC'),
        locale_manager.get('USE') + locale_manager.get('IMAGINATION')
    ]

    items = self.get_items()
    counter_items = Counter(items)
    for i, cnt in counter_items.most_common():
        if i.fightable:
            act = locale_manager.get('USE') + i.name + ' ({0} шт.)'.format(cnt)
            if act not in actions:
                actions.append(act)

    return actions
コード例 #30
0
    def message(self, reply, text):
        self.last_message = datetime.now()

        if self.dead:
            reply(locale_manager.get('DEAD_MESSAGE_AGAIN'), ['/start'])
        elif self.state == 'name':
            self.name_given(reply, text)
        elif self.state == 'name_confirm':
            self.name_confirm(reply, text)
        elif self.state == 'first_msg':
            self.first(reply, text)
        elif self.state == 'corridor':
            self.corridor(reply, text)
        elif self.state == 'pray':
            self.pray(reply, text)
        elif self.state == 'shop':
            self.shop(reply, text)
        elif self.state == 'inventory':
            self.inventory(reply, text)
        elif self.state == 'room':
            self.in_room(reply, text)
        elif self.state == 'dice':
            self.dice(reply, text)
        elif self.state.startswith('pet'):
            self.on_pet(reply, text)
        elif self.state == 'reborned':
            reply(self.reborn_answer, ['/start'])
コード例 #31
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def pray(self, reply, god=None):
        self.state = 'pray'

        if god == None:
            if self.prayed:
                reply(locale_manager.get('FAST_GOD'))
            else:
                reply(locale_manager.get('GOD_ASK'), self.gods)
        elif god not in self.gods:
            reply(locale_manager.get('NO_GOD'), self.gods)
        else:
            if len(self.last_god) > 0 and god != self.last_god:
                self.evilgod(reply, self.last_god)

            self.prayto(reply, god)
            self.last_god = god
コード例 #32
0
def in_room(self, reply, text):
    room = roomloader.load_room(self.room[1], self.room[0], self)
    room.action(self, reply, text)

    if self.state == 'room':
        reply(self.get_stats())
        room = roomloader.load_room(self.room[1], self.room[0], self)
        reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
コード例 #33
0
def corridor(self, reply, text):
	if self.has_tag('wet'):
		self.remove_tag('wet')
	if self.has_tag('wet_enemy'):
		self.remove_tag('wet_enemy')

	if text.startswith(locale_manager.get('OPEN_NEXT_DOOR').split()[0]):
		self.open_room(reply)
	elif text == locale_manager.get('USE_SIGN'):
		self.open_room(reply, 'special', 'sign')
	elif text.startswith(locale_manager.get('PRAY_TO_GOD').split()[0]):
		self.pray(reply)
	elif text.startswith(locale_manager.get('OPEN_SHOP').split()[0]):
		self.open_shop(reply)
	elif text.startswith(locale_manager.get('SHOW_INVENTORY').split()[0]):
		self.inventory_page = 0
		self.open_inventory(reply)
	elif text.startswith(locale_manager.get('PLAYER_CHARACTERISTICS').split()[0]):
		self.show_characteristics(reply)
#	elif text == 'Хеллуин!' and not self.get_variable('halloween_visited', False):
#		self.open_room(reply, 'special', 'helloween_shop')
#		self.set_variable('halloween_visited', True)
	elif text == 'Умереть':
		reply('Пакеда!', photo='BQADAgAD5wgAAmrZzgcHFvPa24KvDwI')
		self.death(reply, reason='Суицид')
	elif text == locale_manager.get('JOIN_TORNAMENT'):
		self.open_room(reply, 'usual', 'cesar')
	elif self.get_prev_level() is not None and text == locale_manager.get('GO_UP'):
		self.level = self.get_prev_level()
		reply('Поднимаясь выше по лестнице, ты заметил, что кто-то написал, какие монстры есть на этом этаже, но не все было разборчиво..')

		msg = ''
		for ind, name in enumerate(roomloader.get_level_rooms(self, self.level)):
			msg += '{0}. {1}\n'.format(ind + 1, name)

		reply(msg)

		self.open_corridor(reply)
	elif self.get_next_level() is not None and text == locale_manager.get('GO_DOWN'):
		self.level = self.get_next_level()
		reply('Спускаясь, ты заметил, что кто-то написал, какие монстры есть на этом этаже, но не все было разборчиво..')

		msg = ''
		for ind, name in enumerate(roomloader.get_level_rooms(self, self.level)):
			msg += '{0}. {1}\n'.format(ind + 1, name)

		reply(msg)

		self.open_corridor(reply)
	else:
		self.open_corridor(reply)
コード例 #34
0
def name_given(self, reply, name):
	if '_' in name:
		reply(locale_manager.get('NAME_ERROR'))
	else:
		n = name
		while n == name:
			usr = usermanager.random_user()
			n = usr.name

		msg = locale_manager.get('NAME_CONFIRM').format(n, name)

		buttons = [ locale_manager.get('NAME_AGREE'), locale_manager.get('NAME_DISMISS') ]
			
		self.state = 'name_confirm'
		self.name = name

		reply(msg, buttons)
コード例 #35
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def evilgod(self, reply, god):
        self.gods_level = [0 for g in self.gods]

        if god == self.gods[0]:  # Buddha
            txt = ()
            reply(locale_manager.get('EVIL_BUDDHA'))
        elif god == self.gods[1]:  # Jesus
            txt = ()
            self.make_damage(5, 10, reply, death=False)
            reply(locale_manager.get('EVIL_JESUS'))
        elif god == self.gods[2]:  # Allah
            self.make_damage(20, 30, reply, name='Аллах')
            reply(locale_manager.get('EVIL_ALLAH'))
        elif god == self.gods[3]:  # Author
            self.add_item('special', 'intoxicated_shoes')

            reply(locale_manager.get('EVIL_AUTHOR'))
コード例 #36
0
ファイル: user.py プロジェクト: satan007/RogueBot
    def open_inventory(self, reply):
        self.state = 'inventory'

        items = self.get_items()
        active_items = self.get_active_items()

        if len(items) == 0:
            self.open_corridor(reply)
            return

        actions = []
        msg = locale_manager.get('INVENTORY_MESSAGE')

        counter_items = Counter(items)
        selected_items = list(counter_items)

        begin = min(self.inventory_page * INVENTORY_PAGE_SIZE,
                    len(selected_items) - 1)
        end = min((self.inventory_page + 1) * INVENTORY_PAGE_SIZE,
                  len(selected_items))

        for i in selected_items[begin:end]:
            if i is not None:
                is_atcive = '(Надето: {0} шт.)'.format(
                    active_items.count(i)) if i in active_items else ''
                msg += '{0} ({2} шт.) {1}:\n{3}\n\n'.format(
                    i.name, is_atcive, counter_items[i], i.description)
                if i.usable:
                    actions.append(i.name)

                if active_items.count(i) > 0:
                    pass  #actions.append(locale_manager.get('DEACTIVATE') + i.name)

                if active_items.count(i) < items.count(i) and (
                        len(active_items) < self.get_active_slots_len()):
                    pass  #actions.append(locale_manager.get('ACTIVATE') + i.name)

                actions.append(locale_manager.get('THROW_AWAY') + i.name)

        if begin > 0:
            actions.append(locale_manager.get('BACK'))
        if end < len(selected_items):
            actions.append(locale_manager.get('NEXT'))

        actions.append(locale_manager.get('TO_CORRIDOR'))
        reply(msg, actions)
コード例 #37
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def fight_answer(self, reply):
        room = roomloader.load_room(self.room[1], self.room[0])

        a, b = room.damage_range
        dmg = self.make_damage(a, b, reply, name=room.name)

        if not self.dead and dmg > 0.2:
            reply(locale_manager.get('USER_DAMAGED').format(dmg))
コード例 #38
0
ファイル: room_defenition.py プロジェクト: yegorf1/RogueBot
def in_room(self, reply, text):
	room = roomloader.load_room(self.room[1], self.room[0], self)
	room.action(self, reply, text)

	if self.state == 'room':
		reply(self.get_stats())
		room = roomloader.load_room(self.room[1], self.room[0], self)
		reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
コード例 #39
0
ファイル: meet_defenition.py プロジェクト: yegorf1/RogueBot
def name_given(self, reply, name):
	if not only_letters(name) or len(name) <= 0:
		reply(locale_manager.get('NAME_ERROR'))
	else:
		n = name
		while n == name:
			usr = usermanager.random_user()
			n = usr.name

		msg = locale_manager.get('NAME_CONFIRM').format(n, name)

		buttons = [ locale_manager.get('NAME_AGREE'), locale_manager.get('NAME_DISMISS') ]
			
		self.state = 'name_confirm'
		self.name = antimat(name)

		reply(msg, buttons)
コード例 #40
0
ファイル: user.py プロジェクト: QumiQumi/Uirs
    def open_corridor(self, reply):
        if self.state == 'room':
            for item in self.get_items():
                item.on_corridor(self, reply)

        self.state = 'corridor'
        reply(self.get_stats())

        buttons = [
            locale_manager.get('OPEN_NEXT_DOOR'),
            locale_manager.get('PLAYER_CHARACTERISTICS')
        ]

        if self.has_item('sign'):
            buttons.append(locale_manager.get('USE_SIGN'))

        if not self.prayed:
            buttons.append(locale_manager.get('PRAY_TO_GOD'))

        if not self.visited_shop:
            buttons.append(locale_manager.get('OPEN_SHOP'))

        if self.race == RAT_RACE:
            buttons.append('Умереть')

        if len(self.items) > 0:
            buttons.append(locale_manager.get('SHOW_INVENTORY'))

        reply(locale_manager.get('WHAT_WILL_WE_DO'), buttons)
コード例 #41
0
def open_room(self, reply, room_type=None, room_name=None):
	if self.race == RAT_RACE:
		reply('Ты крыса, у тебя не хватило сил сдвинуть дверь с места :(')
		self.open_corridor(reply)
		return

	self.state = 'room'

	self.rooms_count += 1
	self.rooms_to_story -= 1

	if not (room_type and room_name):
		if self.rooms_to_story < 1:
			room_type, room_name = 'story', self.next_story_room
		else:
			room_type, room_name = roomloader.get_next_room()

	self.room = (room_type, room_name)
	self.room_temp = { }

	room = roomloader.load_room(self.room[1], self.room[0])

	if room_type == 'story':
		self.story_level += 1
		self.next_story_room = room.next_story_room

		mn, mx = room.next_story_room_range
		self.rooms_to_story = random.randint(mn, mx)

	for i in self.get_items():
		i.on_room(self, reply, room)

	if self.pet:
		self.get_pet().on_room(self, reply, room)

	if room.room_type == 'monster':
		self.set_room_temp('hp', room.hp)

	reply(locale_manager.get('ROOM_OPENED'))
	reply(room.name + '!')

	room.enter(self, reply)

	if self.state == 'room':
		reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))
コード例 #42
0
    def won(self, reply):
        room = roomloader.load_room(self.room[1], self.room[0])

        items = [itemloader.load_item(i, 'loot') for i in room.loot]
        loot = ', '.join([item.name
                          for item in items]) if len(items) > 0 else 'Ничего.'

        for lt in room.loot:
            self.add_item('loot', lt)

        if room.coins > 0:
            reply(locale_manager.get('GOLD_FOUND').format(room.coins))

            self.gold += room.coins

        reply(locale_manager.get('YOU_WON').format(loot))

        self.leave(reply)
コード例 #43
0
def show_characteristics(self, reply):
    msg = locale_manager.get('CHARACTERISTICS').format(self.get_damage(),
                                                       self.get_defence(),
                                                       self.get_charisma(),
                                                       self.get_mana_damage(),
                                                       self.monsters_killed,
                                                       self.rooms_count)

    reply(msg)
    self.open_corridor(reply)
コード例 #44
0
ファイル: gods_defenition.py プロジェクト: yegorf1/RogueBot
def evilgod(self, reply, god):
	self.gods_level = [ 0 for g in self.gods ]

	if god == self.gods[0]: # Buddha
		txt = ()
		reply(locale_manager.get('EVIL_BUDDHA'))
	elif god == self.gods[1]: # Jesus
		txt = ()
		self.make_damage(5, 10, reply, death=False)
		reply(locale_manager.get('EVIL_JESUS'))
	elif god == self.gods[2]: # Allah
		self.make_damage(20, 30, reply, name='Аллах')
		reply(locale_manager.get('EVIL_ALLAH'))
	elif god == self.gods[3]: # Author
		self.add_item('special', 'intoxicated_shoes')
		reply(locale_manager.get('EVIL_AUTHOR'))
	elif god == self.gods[4]: # Emperor
		self.new_buff(EmperorBurn())
		reply(locale_manager.get('EVIL_EMPEROR'))	
コード例 #45
0
ファイル: gods_defenition.py プロジェクト: yegorf1/RogueBot
def pray(self, reply, god=None):
	if self.prayed:
		return self.open_corridor(reply)

	self.state = 'pray'

	if god == None:
		if self.prayed:
			reply(locale_manager.get('FAST_GOD'))
		else:
			reply(locale_manager.get('GOD_ASK'), self.gods)
	elif god not in self.gods:
		reply(locale_manager.get('NO_GOD'), self.gods)
	else:
		if len(self.last_god) > 0 and god != self.last_god:
			self.evilgod(reply, self.last_god)

		self.prayto(reply, god)
		self.last_god = god
コード例 #46
0
ファイル: meet_defenition.py プロジェクト: yegorf1/RogueBot
def first(self, reply, text):
	reply(locale_manager.get('HELLO_MESSAGE'))

	mn = databasemanager.get_variable(str(self.uid) + '_gold')

	if mn is not None and mn:
		databasemanager.set_variable(str(self.uid) + '_gold', False)
		reply('Вы не помните даже кем вы были в той жизни, а вот мы замечательно помним, что получили от вас ровно тысячу. Да. Точно-точно. Нет, не развод.')
		self.give_gold(1000)

	self.open_corridor(reply)
コード例 #47
0
ファイル: stats_defenition.py プロジェクト: yegorf1/RogueBot
def show_characteristics(self, reply):
	msg = locale_manager.get('CHARACTERISTICS').format(
		self.get_damage(), 
		self.get_defence(), 
		self.get_charisma(),
		self.get_mana_damage(),
		self.monsters_killed,
		self.rooms_count
	)

	reply(msg)
	self.open_corridor(reply)
コード例 #48
0
ファイル: fight_defenition.py プロジェクト: yegorf1/RogueBot
def fight_dice(self, reply, result, subject=None):
	room = roomloader.load_room(self.room[1], self.room[0], self)
	if subject == 'noname':
		dmg = result + self.get_damage_bonus(reply) // 2

		reply(locale_manager.get('IMAGINATION_FIGHT').format(dmg))

		room.make_damage(self, reply, dmg)
		
		if self.state == 'room':
			self.fight_answer(reply)
			reply(self.get_stats())
コード例 #49
0
ファイル: gods_defenition.py プロジェクト: yegorf1/RogueBot
def prayto(self, reply, god):
	god_num = -1

	if god == self.gods[BUDDHA_NUM]: # Buddha
		reply(locale_manager.get('BUDDHA_PRAYED'))
		god_num = BUDDHA_NUM
	elif god == self.gods[JESUS_NUM]: # Jesus
		reply(locale_manager.get('JESUS_PRAYED'))
		god_num = JESUS_NUM
	elif god == self.gods[ALLAH_NUM]: # Allah
		reply(locale_manager.get('ALLAH_PRAYED'))
		god_num = ALLAH_NUM
	elif god == self.gods[AUTHOR_NUM]: # Author
		reply(locale_manager.get('AUTHOR_PRAYED'))
		god_num = AUTHOR_NUM
	elif god == self.gods[EMPEROR_NUM]: # Emperor
		reply(locale_manager.get('EMPEROR_PRAYED'))
		god_num = EMPEROR_NUM	
	else:
		reply(locale_manager.get('NO_GOD'))

	if god_num >= 0:
		self.gods_level[god_num] += 1

		for item in self.get_items():
			item.on_pray(self, reply, god_num)


		if self.gods_level[god_num] >= GOD_LEVEL:
			self.god_love(reply, god_num)


	if self.state == 'pray':
		self.prayed = True
		self.open_corridor(reply)
コード例 #50
0
def open_corridor(self, reply):
	if self.state == 'room':
		for item in self.get_items():
			item.on_corridor(self, reply)

	self.state = 'corridor'
	reply(self.get_stats())

	buttons = [ 
		locale_manager.get('OPEN_NEXT_DOOR'), 
		locale_manager.get('PLAYER_CHARACTERISTICS')#, locale_manager.get('JOIN_TORNAMENT')
	]

#	if not self.get_variable('halloween_visited', False) and self.rooms_pack == 'default':
#		buttons.append('Хеллуин!')

	if self.has_item('sign'):
		buttons.append(locale_manager.get('USE_SIGN'))

	levels_acts = [ ]
	if self.get_next_level() is not None:
		levels_acts.append(locale_manager.get('GO_DOWN'))

	if self.get_prev_level() is not None:
		levels_acts.append(locale_manager.get('GO_UP'))

	if len(levels_acts) > 0:
		buttons.append(levels_acts)

	if not self.prayed:
		buttons.append(locale_manager.get('PRAY_TO_GOD'))

	if not self.visited_shop:
		buttons.append(locale_manager.get('OPEN_SHOP'))

	if self.race == RAT_RACE:
		buttons.append('Умереть')		

	if len(self.items) > 0:
		buttons.append(locale_manager.get('SHOW_INVENTORY'))

	reply(locale_manager.get('WHAT_WILL_WE_DO'), buttons)
コード例 #51
0
ファイル: fight_defenition.py プロジェクト: yegorf1/RogueBot
def fight_answer(self, reply):
	room = roomloader.load_room(self.room[1], self.room[0], self)
	if room.code_name == 'tornament':
		return

	room_type, room_name = self.room
	if room_type == 'boss':
		boss = bossmanager.current()
		user_boss_id = self.get_room_temp('boss_id', def_val=0)

		if boss.get('alive') is False or boss.get('id') is not user_boss_id:
			return

	a, b = room.damage_range
	dmg = self.make_damage(a, b, reply, name=room.name)

	if not self.dead and dmg > 0.2:
		reply(locale_manager.get('USER_DAMAGED').format(dmg))
コード例 #52
0
ファイル: __init__.py プロジェクト: yegorf1/RogueBot
	def message(self, reply, text):
		self.last_message = datetime.now()
		logger.info('msg from {0}'.format(self.uid))

		if self.dead:
			reply(locale_manager.get('DEAD_MESSAGE_AGAIN'), [ '/start' ], photo='BQADAgADWAkAAmrZzgf8dV_v2nf2uQI')
		elif self.state == 'name':
			self.name_given(reply, text)
		elif self.state == 'name_confirm':
			self.name_confirm(reply, text)
		elif self.state == 'first_msg':
			self.first(reply, text)
		elif self.state == 'corridor':
			self.corridor(reply, text)
		elif self.state == 'pray':
			self.pray(reply, text)
		elif self.state == 'shop':
			self.shop(reply, text)
		elif self.state == 'inventory':
			self.inventory(reply, text)
		elif self.state == 'room':
			self.in_room(reply, text)
		elif self.state == 'dice':
			self.dice(reply, text)
		elif self.state.startswith('pet'):
			self.on_pet(reply, text)
		elif self.state == 'reborned':
			reply(self.reborn_answer, [ '/start' ])
		elif self.state.startswith('restart'):
			if text == 'Начать новую игру':
				reply('Приговор приведен в исполнение.\nТеперь скажи мне свое новое имя')
				return True
			else:
				reply('Не в этот раз.')
				try:
					self.state = self.state.split()[1]
				except:
					self.state = 'corridor'

		return False
コード例 #53
0
def open_inventory(self, reply):
    self.state = "inventory"

    items = self.get_items()
    active_items = self.get_active_items()

    if len(items) == 0:
        self.open_corridor(reply)
        return

    actions = []
    msg = locale_manager.get("INVENTORY_MESSAGE")

    counter_items = Counter(items)
    selected_items = list(counter_items)

    begin = min(self.inventory_page * INVENTORY_PAGE_SIZE, len(selected_items) - 1)
    end = min((self.inventory_page + 1) * INVENTORY_PAGE_SIZE, len(selected_items))

    for i in selected_items[begin:end]:
        if i is not None:
            acts = []
            is_atcive = ""  #'(Надето: {0} шт.)'.format(active_items.count(i)) if i in active_items else ''
            msg += "{0} ({2} шт. ценой {4} злт.) {1}:\n{3}\n\n".format(
                i.name, is_atcive, counter_items[i], i.description, round(i.price * 0.7)
            )
            if i.usable:
                acts.append(i.name)

            if active_items.count(i) > 0:
                pass  # actions.append(locale_manager.get('DEACTIVATE') + i.name)

            if active_items.count(i) < items.count(i) and (len(active_items) < self.get_active_slots_len()):
                pass  # actions.append(locale_manager.get('ACTIVATE') + i.name)

            acts.append(locale_manager.get("THROW_AWAY") + i.name)
            acts.append(locale_manager.get("SELL") + i.name)

            actions.append(acts)

    if begin > 0:
        actions.append(locale_manager.get("BACK"))
    if end < len(selected_items):
        actions.append(locale_manager.get("NEXT"))

    actions.append(locale_manager.get("TO_CORRIDOR"))
    reply(msg, actions)
コード例 #54
0
ファイル: shop_defenition.py プロジェクト: yegorf1/RogueBot
def buy(self, item, reply):
	if self.paid(item.price):
		if item.buff == 'bad':
			reply(locale_manager.get('BAD_BUYED'))
		elif item.buff == 'good':
			reply(locale_manager.get('GOOD_BUYED'))
		else:
			reply(locale_manager.get('NEUTRAL_BUYED'))

		check = locale_manager.get('SHOP_CHECK').format(strftime("%Y-%m-%d %H:%M:%S UTC", gmtime()), item.name, item.shop_count, item.price, item.price)

		for i in range(item.shop_count):
			self.add_item(item.buff, item.code_name)
		item.on_buy(self, reply)
		reply(check)

		self.shop_items = [ ]
		self.visited_shop = True
		self.open_corridor(reply)
	else:
		reply(locale_manager.get('NO_GOLD'), [ self.shop_names[0:2], self.shop_names[2:], locale_manager.get('EXIT') ])
コード例 #55
0
ファイル: stats_defenition.py プロジェクト: yegorf1/RogueBot
def get_stats(self):
	return locale_manager.get('USER_STATS').format(self.hp, self.mp, self.gold)
コード例 #56
0
def inventory(self, reply, text):
    if text == locale_manager.get("TO_CORRIDOR"):
        self.open_corridor(reply)
    elif False and text.startswith(locale_manager.get("ACTIVATE")):
        name = text[len(locale_manager.get("ACTIVATE")) :]

        item = self.get_item_by_name(name)

        items = self.get_items()
        active_items = self.get_active_items()

        if (
            item is not None
            and active_items.count(item) < items.count(item)
            and (len(active_items) < self.get_active_slots_len())
        ):
            self.active_items.append((item.buff, item.code_name))
            reply(locale_manager.get("ACTIVATED"))
        else:
            reply(locale_manager.get("CANT_ACTIVATE"))

        self.open_inventory(reply)
    elif False and text.startswith(locale_manager.get("DEACTIVATE")):
        name = text[len(locale_manager.get("DEACTIVATE")) :]

        item = self.get_item_by_name(name)

        self.deactivate_item_by_name(name)
        self.open_inventory(reply)
    elif text.startswith(locale_manager.get("THROW_AWAY")):
        name = text[len(locale_manager.get("THROW_AWAY")) :]

        if not self.remove_item_by_name(name):
            reply(locale_manager.get("CANT_THROW"))

        self.open_inventory(reply)
    elif text.startswith(locale_manager.get("SELL")):
        name = text[len(locale_manager.get("SELL")) :]

        item = self.get_item_by_name(name)
        if not self.remove_item_by_name(name):
            reply("Не продается")
            self.open_inventory(reply)
        else:
            reply("Золотишко-то.. Звенит!")
            self.give_gold(round(item.price * 0.7))
            self.open_inventory(reply)
    elif text == locale_manager.get("BACK"):
        self.inventory_page = max(self.inventory_page - 1, 0)
        self.open_inventory(reply)
    elif text == locale_manager.get("NEXT"):
        self.inventory_page = self.inventory_page + 1
        self.open_inventory(reply)
    else:
        items = self.get_items()

        for i in items:
            if i.name == text:
                i.on_use(self, reply)

                if i.disposable:
                    self.remove_item(i.code_name)

                break

        if self.state == "inventory":
            self.open_corridor(reply)
コード例 #57
0
ファイル: room_defenition.py プロジェクト: yegorf1/RogueBot
def open_room(self, reply, room_type=None, room_name=None):
	if room_name != 'halloween_shop':
		self.set_variable('halloween_visited', False)

	if self.race == RAT_RACE:
		reply('Ты — крыса, у тебя не хватило сил сдвинуть дверь с места :(')
		self.open_corridor(reply)
		return

	self.state = 'room'

	self.rooms_count += 1
	for m in self.missions:
		m.room_opened()

	if not (room_type and room_name):
		room_type, room_name = roomloader.get_next_room(self)

	logger.info('room_opened ' + room_name)

	last_mission = self.get_last_mission()
	if last_mission.get_room_type() == room_type and last_mission.get_room_name() == room_name:
		self.pop_mission()

	self.room = (room_type, room_name)
	self.room_temp = { }

	visited = self.get_perma_variable('visited_rooms', def_val=[])
	if room_name not in visited:
		visited.append(room_name)
	self.set_perma_variable('visited_rooms', visited)
	statistics.track(self.uid, {'uid': self.uid, 'name': room_name, 'type': room_type}, 'Room opened')

	room = roomloader.load_room(self.room[1], self.room[0], self)

	for i in self.get_items():
		i.on_room(self, reply, room)

	to_delete = [ ]
	for i, b in enumerate(self.buffs):
		try:
			b.on_room(self, reply, room)
			if b.time <= 0:
				to_delete.append(i)
		except:
			pass

	for i in reversed(to_delete):
		self.buffs[i].on_end(self, reply, room)
		del self.buffs[i]

	if self.pet:
		self.get_pet().on_room(self, reply, room)

	if room.room_type == 'monster':
		self.set_room_temp('hp', room.hp)

	reply(locale_manager.get('ROOM_OPENED'))
	reply(room.name + '!')

	room.enter(self, reply)

	if self.state == 'room':
		reply(locale_manager.get('YOUR_ACTIONS'), room.get_actions(self))

	if not room.can_open(self, reply):
		room.open_failure(self, reply)

		self.open_corridor(reply)
		return
コード例 #58
0
ファイル: room_defenition.py プロジェクト: yegorf1/RogueBot
def throw_dice(self, reply, subject=None):
	self.state = 'dice'
	self.subject = subject

	reply(locale_manager.get('DICE_TIME'), [locale_manager.get('THOW_DICE')])
コード例 #59
0
ファイル: __init__.py プロジェクト: yegorf1/RogueBot
	def __init__(self, uid):
		super(User, self).__init__()

		self.uid = uid
		self.session = time.time()

		self.name = 'none'
		self.hp = 100
		self.mp = 100
		self.gold = 200
		self.race = HUMAN

		self.max_hp = 150
		self.max_mp = 150

		self.state = 'name'

		self.items = [ ]
		self.active_items = [ ]
		self.inventory_page = 0

		self.gods = [ locale_manager.get('BUDDHA'), locale_manager.get('JESUS'), locale_manager.get('ALLAH'), locale_manager.get('AUTHOR'), locale_manager.get('EMPEROR') ]
		self.gods_level = [ 0 for g in self.gods ]
		self.last_god = ''
		self.prayed = False

		self.damage = 10
		self.defence = 1
		self.charisma = 0
		self.mana_damage = 0

		self.visited_shop = False
		self.shop_items = [ ]
		self.shop_names = [ ]

		self.tags = [ ]

		self.levels = [ 'easy' ]
		self.level = 'easy'
		self.room = ('', '')
		self.room_temp = { }
		self.rooms_pack = 'default'

		self.reborn_answer = None
		self.dead = False

		self.last_message = datetime.now()
		self.rooms_count = 0
		self.monsters_killed = 0

		self.subject = None

		self.race = 'human'
		self.pet = None

		self.costume = 'none'

		self.variables = dict()
		self.missions = list()
		self.buffs = list()

		self.new_mission('main')
		self.new_mission('tips', 'tips', path_len=30)
		self.new_mission('caravan', path_len=20)