This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gameState、通信状態によってcontrollerがアクティブか変わるように実装
- Loading branch information
Showing
5 changed files
with
108 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import eventPublisher from "./publisher"; | ||
|
||
function InactiveStatus() { | ||
this.inactiveScreen = document.getElementById("inactive-screen"); | ||
this.inactiveInner = document.getElementById("inactive-inner"); | ||
eventPublisher.subscribe("gameState", (gameState) => { | ||
this.changeStatus(gameState); | ||
}); | ||
eventPublisher.subscribe("ws-connected", () => { | ||
this.changeStatus("connected"); | ||
}); | ||
eventPublisher.subscribe("ws-error", () => { | ||
this.changeStatus("error"); | ||
}); | ||
eventPublisher.subscribe("ws-not-found", () => { | ||
this.changeStatus("not-found"); | ||
}); | ||
} | ||
|
||
InactiveStatus.prototype.changeStatus = function(screenState) { | ||
switch (screenState) { | ||
case "disconnected": | ||
this.inactiveInner.textContent = "サーバーに接続されていません"; | ||
break; | ||
case "not-found": | ||
this.inactiveInner.textContent = "サーバーが見つかりませんでした"; | ||
break; | ||
case "error": | ||
this.inactiveInner.textContent = "通信でエラーが発生しました"; | ||
break; | ||
case "connected": | ||
this.inactiveInner.textContent = "サーバーに接続されました。ゲームの状態の受信を待機しています..."; | ||
break; | ||
case "inactive": | ||
this.inactiveInner.textContent = "ゲームは開始されていません"; | ||
break; | ||
} | ||
if (screenState === "active") this.inactiveScreen.classList.add("screen-game-active"); | ||
else this.inactiveScreen.classList.remove("screen-game-active"); | ||
}; | ||
|
||
export default InactiveStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters