update for python 3.8
This commit is contained in:
parent
71a2d4fdf3
commit
aa77da14df
2 changed files with 31 additions and 10 deletions
|
@ -5,7 +5,7 @@ It's a python clone of [@mine_sweeper_bot](https://github.com/hczhcz/telegram-ku
|
||||||
The bot is currently running as [@archcnmsbot](http://telegram.me/archcnmsbot).
|
The bot is currently running as [@archcnmsbot](http://telegram.me/archcnmsbot).
|
||||||
|
|
||||||
To run the bot yourself, you will need:
|
To run the bot yourself, you will need:
|
||||||
- Python3
|
- Python 3.8+
|
||||||
- Numpy
|
- Numpy
|
||||||
- [peewee ORM](http://docs.peewee-orm.com/en/latest/peewee/installation.html)
|
- [peewee ORM](http://docs.peewee-orm.com/en/latest/peewee/installation.html)
|
||||||
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module
|
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module
|
||||||
|
|
39
cards.py
39
cards.py
|
@ -189,16 +189,37 @@ def rob_cards(update, context):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
if __chance(success_chance):
|
MSG_TEXT_SUCCESS = "抢劫成功,获得"
|
||||||
msg_text = "抢劫成功,获得"
|
MSG_TEXT_FAIL = "抢劫失败,反被抢走"
|
||||||
|
if _fp >= MID_LEVEL and _tp >= MID_LEVEL:
|
||||||
|
cards_amount = int(max(abs(fplayer.immunity_cards), abs(tplayer.immunity_cards)) * randrange(1000,8000)/10000)
|
||||||
|
lvl_amount = int(max(_fp, _tp) * randrange(1000,8000)/10000)
|
||||||
|
if (_tple if (_fp < MAX_LEVEL) ^ (_tple := _tp < MAX_LEVEL) else __chance(success_chance)):
|
||||||
|
msg_text = MSG_TEXT_SUCCESS
|
||||||
|
else:
|
||||||
|
msg_text = MSG_TEXT_FAIL
|
||||||
|
cards_amount = -cards_amount
|
||||||
|
lvl_amount = -lvl_amount
|
||||||
|
fplayer.immunity_cards += cards_amount
|
||||||
|
tplayer.immunity_cards -= cards_amount
|
||||||
|
fplayer.permission = _fpp if (_fpp := _fp + lvl_amount) < MAX_LEVEL or _fp >= MAX_LEVEL else MAX_LEVEL - 1
|
||||||
|
tplayer.permission = _tpp if (_tpp := _tp - lvl_amount) < MAX_LEVEL or _tp >= MAX_LEVEL else MAX_LEVEL - 1
|
||||||
|
fplayer.save()
|
||||||
|
tplayer.save()
|
||||||
|
update.message.reply_text((f'{display_username(from_user)} {msg_text}{abs(cards_amount)}张卡, '
|
||||||
|
f'{abs(lvl_amount)}级'),
|
||||||
|
parse_mode="Markdown")
|
||||||
else:
|
else:
|
||||||
msg_text = "抢劫失败,反被抢走"
|
if __chance(success_chance):
|
||||||
amount = -amount
|
msg_text = MSG_TEXT_SUCCESS
|
||||||
fplayer.immunity_cards += amount
|
else:
|
||||||
tplayer.immunity_cards -= amount
|
msg_text = MSG_TEXT_FAIL
|
||||||
fplayer.save()
|
amount = -amount
|
||||||
tplayer.save()
|
fplayer.immunity_cards += amount
|
||||||
update.message.reply_text(f'{display_username(from_user)} {msg_text}{abs(amount)}张卡', parse_mode="Markdown")
|
tplayer.immunity_cards -= amount
|
||||||
|
fplayer.save()
|
||||||
|
tplayer.save()
|
||||||
|
update.message.reply_text(f'{display_username(from_user)} {msg_text}{abs(amount)}张卡', parse_mode="Markdown")
|
||||||
else:
|
else:
|
||||||
update.message.reply_text('请回复被操作人')
|
update.message.reply_text('请回复被操作人')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue