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

Feature/donghoon/refactor codes #4

Merged
merged 6 commits into from Sep 14, 2022
Merged

Conversation

589hero
Copy link
Member

@589hero 589hero commented Sep 5, 2022

  • Chess Bot 코드 리팩토링 작업을 거쳤습니다.



def get_legal_moves(user_id: str) -> List[str]:
legal_moves = list(user_chess[user_id].legal_moves)
Copy link
Member

@byeongal byeongal Sep 7, 2022

Choose a reason for hiding this comment

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

minor) user_chess 선언 부분을 82번째 줄 보다 위에 있는게 좋을 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

반영했습니다

src/bot.py Outdated
# 사용자가 게임을 시작 안했거나 게임이 끝나, 체스판 정보에 없을 때에 /move 시도 시 에러 표기 (Discord)
if interaction.user.id not in user_chess.keys():
if user_id not in user_chess.keys():
Copy link
Member

Choose a reason for hiding this comment

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

user_id not in user_chess.keys(): -> user_id not in user_chess:

Copy link
Member Author

Choose a reason for hiding this comment

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

수정했습니다!

Copy link
Member

@Laeyoung Laeyoung left a comment

Choose a reason for hiding this comment

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

저는 잘 몰라서ㅠ

@@ -38,17 +41,18 @@ async def on_ready(self):
print(f"We have logged in as {self.user}.")


client = aclient()
Copy link
Member

Choose a reason for hiding this comment

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

이거 원래 이름이 ㅋㅋㅋㅋㅋㅋ

Copy link
Member Author

Choose a reason for hiding this comment

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

호다닥 바꿨습니다ㅋㅋㅋ

return embed, display_board(user_chess[interaction.user.id])
view = View()
await interaction.response.send_message(
embed=embed, file=display_board(user_chess[user_id]), view=view, ephemeral=True
Copy link
Member

Choose a reason for hiding this comment

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

minor) ephemeral=True가 다른 사람이 메세지를 못 보는데 이럴 경우 해당 봇이 죽었는지 살았는지 모를 것 같습니다.

del user_prompt[interaction.user.id]
await interaction.followup.send("<@" + str(interaction.user.id) + "> won the game.", ephemeral=True)
delete_user_chess_info(user_id)
await interaction.followup.send(f"<@{user_id}> won the game.", ephemeral=True)
Copy link
Member

Choose a reason for hiding this comment

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

minor) ditto

await interaction.followup.send("<@" + str(interaction.user.id) + "> lost the game.", ephemeral=True)
if not legal_moves:
delete_user_chess_info(user_id)
await interaction.followup.send(f"<@{user_id}> lost the game.", ephemeral=True)
Copy link
Member

Choose a reason for hiding this comment

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

minor) ditto

)
async def button_callback(interaction: discord.Interaction):
delete_user_chess_info(user_id)
await interaction.response.send_message(f"<@{user_id}> resigned the game.", ephemeral=True)
Copy link
Member

Choose a reason for hiding this comment

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

minor) ditto

user_color = {} # {'user_id': 'White', ...}
user_count = defaultdict(int) # {'user_id': 1, ...}
user_prompt = defaultdict(list) # {'user_id': ['1.', 'e4', 'e5'], ...}
await interaction.followup.send(embed=embed, file=display_board(user_chess[user_id]), view=view, ephemeral=True)
Copy link
Member

Choose a reason for hiding this comment

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

minor) ditto

Copy link
Member

@byeongal byeongal left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments

@589hero 589hero merged commit aaac723 into develop Sep 14, 2022
@589hero 589hero deleted the feature/donghoon/refactor-codes branch September 14, 2022 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants