Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character creation error message fix #163

Merged
merged 2 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import random

from dnd_bot.database.database_game import DatabaseGame
from dnd_bot.dc.ui.messager import Messager
from dnd_bot.dc.utils.message_holder import MessageHolder
from dnd_bot.logic.character_creation.chosen_attributes import ChosenAttributes
from dnd_bot.logic.game.game_loop import GameLoop
from dnd_bot.logic.game.game_start import GameStart
Expand Down Expand Up @@ -112,6 +114,14 @@ async def handle_character_creation_finished(user_id, token) -> (bool, bool, str
if game.all_users_ready():
game.game_state = 'ACTIVE'
DatabaseGame.update_game_state(game_id, 'ACTIVE')

# delete any error message from character creation
for user in game.user_list:
error_data = MessageHolder.read_last_error_data(user.discord_id)
if error_data is not None:
MessageHolder.delete_last_error_data(user.discord_id)
await Messager.delete_message(error_data[0], error_data[1])

GameStart.start(token)
await GameLoop.start_loop(token)

Expand Down
3 changes: 2 additions & 1 deletion dnd-bot/dnd_bot/logic/game/handler_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ async def handle_attack(source: Creature, target: Creature, token) -> (bool, str
else:
attack_status_message = f'**{source.name}** has attacked **{target.name}**!\n\n'

source.action_points -= source.equipment.right_hand.action_points

# dodging an attack
# the chance is (source dexterity)%
if random.randint(0, 99) <= source.dexterity: # evasion
Expand All @@ -50,7 +52,6 @@ async def handle_attack(source: Creature, target: Creature, token) -> (bool, str
weapon_damage += random.randint(*source.equipment.right_hand.damage)

target.hp -= (base_damage + weapon_damage)
source.action_points -= source.equipment.right_hand.action_points

if target.hp <= 0:
target_name = target.name
Expand Down