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

Typing game #64

Closed
wants to merge 63 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5fa96fc
1人用の簡易的なタイピングゲーム
subarunrun0812 Jun 24, 2024
1034094
表示される要素を画面中央に配置
subarunrun0812 Jun 25, 2024
087efca
残り時間を円グラフで描画
subarunrun0812 Jun 25, 2024
273c059
単語を入力し終わっても、時間がリセットされないバグを修正
subarunrun0812 Jun 25, 2024
df83124
ゲーム中に入力された文字を表示する要素を修正
subarunrun0812 Jun 25, 2024
f0f5d1c
制限時間の短縮
subarunrun0812 Jun 25, 2024
3ea5406
bug: 不正解時に時間が減らない
subarunrun0812 Jun 25, 2024
e966046
入力ミス時のペナルティ
subarunrun0812 Jun 25, 2024
098f259
player image画像を配置
subarunrun0812 Jun 25, 2024
626034f
csvファイルから単語を取得
subarunrun0812 Jun 26, 2024
13e95af
単語の追加
subarunrun0812 Jun 26, 2024
a975a58
refactor
subarunrun0812 Jun 26, 2024
1c83860
refactor
subarunrun0812 Jun 27, 2024
af3e260
bug:araiさんにdockerの設定をしてもらった
subarunrun0812 Jun 27, 2024
e348510
fix: asgi.py
subarunrun0812 Jun 27, 2024
a8a5590
feat: create new realtime app
massahito Jul 7, 2024
69830b2
fix: change app name to realtime_pong_game
massahito Jul 7, 2024
102cd8b
feat: add consumers to realtime_pong_game
massahito Jul 7, 2024
783bf19
feat: add RoomManager to manage room event
massahito Jul 7, 2024
3a0ae48
fix: make consumers work
massahito Jul 7, 2024
a812eba
feat: add Participants State Management
massahito Jul 7, 2024
452d965
feat: change room state when room is full
massahito Jul 7, 2024
472c41e
feat: add action when user is connected and disconnected
massahito Jul 10, 2024
fbf5aa0
feat: add frontend
massahito Jul 10, 2024
4c9d6ae
Merge branch 'develop' into 73-create-realtime-pong
massahito Jul 10, 2024
a064045
feat: allow to communicate with room-manager
massahito Jul 12, 2024
0bdcb5a
feat: enable PoingGame to communicate with users
massahito Jul 12, 2024
f1da543
Merge branch 'develop' into typing-game
subarunrun0812 Jul 20, 2024
5d1dc94
feat: add game -logic
massahito Jul 20, 2024
5df4524
feat: add event handler
massahito Jul 20, 2024
b9fa126
feat: enable to send message individual from room-manager
massahito Jul 20, 2024
3490a2f
feat: add async_to_sync
massahito Jul 20, 2024
c709bf1
remote用のappを作成し始め
subarunrun0812 Jul 21, 2024
2af3434
tutorial:01
subarunrun0812 Jul 21, 2024
a105efc
feat: ゲームの処理を動かせるようにする。
massahito Jul 21, 2024
3e10aac
feat: send message to client when playerscore
massahito Jul 23, 2024
baba04c
chore: change disconnect behavior
massahito Jul 24, 2024
52e9c35
feat: change file name
massahito Jul 24, 2024
4a8ca99
feat: enable go back to home when matching
massahito Jul 24, 2024
cf49e99
Merge branch 'develop' into 73-create-realtime-pong
massahito Jul 24, 2024
618fd34
fix: liter
massahito Jul 24, 2024
2cba045
fix: linter
massahito Jul 24, 2024
4017466
fix: linter
massahito Jul 24, 2024
c2f5bd5
pongディレクトリ配下でtyping_game appを作成
subarunrun0812 Jul 25, 2024
bd2280c
typing-gameのディレクトリ整理
subarunrun0812 Jul 25, 2024
061e321
インデックスビューを追加
subarunrun0812 Jul 25, 2024
1d2b247
Merge remote-tracking branch 'origin/develop' into typing-game
subarunrun0812 Jul 27, 2024
05019ac
directory移動
subarunrun0812 Jul 27, 2024
0ee00f5
fix: change variable name and add space line at the end of file.
massahito Jul 28, 2024
6c0bfeb
Merge branch 'develop' into 73-create-realtime-pong
massahito Jul 28, 2024
46e607c
fix: change file and class name
massahito Jul 28, 2024
02dced9
Merge remote-tracking branch 'origin/develop' into typing-game
subarunrun0812 Aug 1, 2024
cd5e580
feat: change enum to appropriate name
massahito Aug 1, 2024
a5c87da
fix: change enum class name
massahito Aug 1, 2024
d70ec32
fix: None check of RoomManager when client disconnect
massahito Aug 1, 2024
f63d8cf
Merge branch '73-create-realtime-pong' into typing-game
subarunrun0812 Aug 1, 2024
dab89b7
bugfix: 試合中のdisconnectに対応することで、roomに再接続した際のバグを解決しました。
massahito Aug 1, 2024
9196c3d
pongをもとにtyping-game-homeを作成中
subarunrun0812 Aug 1, 2024
f204b49
araiさんのbranchをmargeする前にcommit
subarunrun0812 Aug 1, 2024
4af1444
Merge remote-tracking branch 'origin/73-create-realtime-pong' into ty…
subarunrun0812 Aug 1, 2024
40f30a0
fix: import
subarunrun0812 Aug 1, 2024
2eade2f
同じサーバーに入れた。ゲームロジックは未実装。
subarunrun0812 Aug 1, 2024
bd8e550
SPAに対応
subarunrun0812 Aug 2, 2024
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
Prev Previous commit
Next Next commit
fix: change enum class name
  • Loading branch information
massahito committed Aug 1, 2024
commit a5c87da5cf4ffde6bc96e4ecda1afd3494bcc478
16 changes: 8 additions & 8 deletions pong/realtime_pong_game/roommanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RoomState(Enum):
Finished = "finished"


class ParticipantsState(Enum):
class ParticipantState(Enum):
Not_In_Place = "not-in-place"
Ready = "ready"
Player1 = "player1"
Expand Down Expand Up @@ -63,7 +63,7 @@ async def on_user_connected(self, user):
if user in self.participants:
return (False, "user already exists in this room")
self.participants.append(user)
self.participants_state[user] = ParticipantsState.Not_In_Place
self.participants_state[user] = ParticipantState.Not_In_Place
if len(self.participants) == self.max_of_participants:
self.room_state = RoomState.Ready
await self.send_messege_to_group(
Expand Down Expand Up @@ -113,9 +113,9 @@ async def on_receive_user_message(self, participant, message):
async def user_became_ready_for_game(self, participant, message_json):
with self.instance_lock:
# TODO validate the contents of message_json
self.participants_state[participant] = ParticipantsState.Ready
self.participants_state[participant] = ParticipantState.Ready
if all(
ParticipantsState.Ready == self.participants_state[key]
ParticipantState.Ready == self.participants_state[key]
for key in self.participants_state
):
self.room_state = RoomState.In_Game
Expand All @@ -125,10 +125,10 @@ async def user_became_ready_for_game(self, participant, message_json):
{"sender": "room-manager", "type": "all-participants-ready"},
)
self.participants_state[self.participants[0]] = (
ParticipantsState.Player1
ParticipantState.Player1
)
self.participants_state[self.participants[1]] = (
ParticipantsState.Player1
ParticipantState.Player1
)
asyncio.new_event_loop().run_in_executor(
None,
Expand All @@ -146,7 +146,7 @@ def game_dispatcher(self, player1_name, player2_name):
)

async def handle_game_action(self, participant, message_json):
if self.participants_state[participant] == ParticipantsState.Player1:
if self.participants_state[participant] == ParticipantState.Player1:
await self.pong_game.recieve_player1_input(message_json)
elif self.participants_state[participant] == ParticipantsState.Player2:
elif self.participants_state[participant] == ParticipantState.Player2:
await self.pong_game.recieve_player2_input(message_json)