Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Less items. Closes #291 #292

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

iliakonnov
Copy link

Надеюсь, багов нет =)

logger = logging.getLogger('rg')


class item_info(object):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless inheritance

return self.context is None or len(self.context) == 0

def __repr__(self):
return "<item {g}/{n} x {cnt}{ctx}".format(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad naming

if item is None:
return None
item = check_item(item, name, buff)
item.count=count
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

import config
from items import item_info

for i in os.listdir(config.USERS_PATH):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use usermanager.get_telegram_users instead

@@ -0,0 +1,23 @@
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(sys.argv[0], '..', '..')))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh god.
This type of scripts we need to call from root of the project so, there is no need to add something to path

@@ -23,11 +23,15 @@ def get_actions(user):
return [ 'Зуб', 'Палка', 'Парашок', 'Уйти' ]

def action(user, reply, text):
teeths = user.get_item_by_name('tooth')
if teeths is None:
user_teeth_cnt = 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternary operator will be better therer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's impossible here. teeths variable used two times.

@@ -29,13 +32,13 @@ def enter(user, reply):
reply('Здесь лежат останки игрока {0}'.format(found_user.name), photo='BQADAgADFwkAAmrZzgf5q0m1CmsDggI')
user.set_room_temp('items', found_user.items)
else:
reply('Здесь лежат останки лягушки. Воняет. Ты уходишь отсюда побыстрее.')
reply('Здесь лежат останки лягушки. Воняет. Ты уходишь отсюда побыстрее.', photo='BQADAgADFwkAAmrZzgf5q0m1CmsDggI')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not the part of issue, but thx


item = self.get_item_by_name(name)
active_item = self.get_active_item_by_name(name)
if (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh god.

for i in items:
if i.name == name:
return i
found = _find_item_by_name(items, name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i, item = _find_item_by_name(items, name)
return item

found = _find_item_by_name(items, name)
if found is not None:
return found[1]
return None

def get_items(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename get_items to get_item_infos

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns items, not item_infos.


def remove_item(self, code_name):
def remove_item(self, code_name, count=1):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we will have some item of one code_name with and without context it won't work right

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants