added who won text
This commit is contained in:
parent
39d4e138a9
commit
c8e354c159
@ -171,7 +171,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
|
||||
minWidth: "10vw",
|
||||
minHeight: "1vw",
|
||||
background: "#2F2504",
|
||||
color : "white",
|
||||
color: "white",
|
||||
}}>
|
||||
{connectionStateText()}
|
||||
</div>}
|
||||
@ -187,7 +187,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
|
||||
<h1 style={{ margin: "10px 0px" }}>{context.texts.Mancala}</h1>
|
||||
<div>
|
||||
{renderNewGameButton()}
|
||||
{game && !userKeyWhoLeave && !crashMessage && < Button color="#005f73" text={context.texts.Leave} onClick={leaveGame} />}
|
||||
{game && !userKeyWhoLeave && !crashMessage && game?.state == "playing" && < Button color="#005f73" text={context.texts.Leave} onClick={leaveGame} />}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -42,7 +42,11 @@ const InfoPanel: FunctionComponent<{
|
||||
|
||||
if (game) {
|
||||
if (game.state == "ended") {
|
||||
const whoWon = game.getWonPlayer() == userKey ? context.texts.YouWon : context.texts.YouLost
|
||||
const wonPlayer = game.getWonPlayer()
|
||||
let whoWon = game.getWonPlayer() == userKey ? context.texts.YouWon : context.texts.YouLost
|
||||
if(!wonPlayer){
|
||||
whoWon = context.texts.GameDraw
|
||||
}
|
||||
return (
|
||||
<h4>{
|
||||
context.texts.GameEnded + " " + whoWon
|
||||
|
||||
@ -19,7 +19,8 @@ export type Texts = {
|
||||
OpponentLeavesTheGame: string,
|
||||
YouLeftTheGame: string,
|
||||
SearchingOpponent: string,
|
||||
PleaseWait : string
|
||||
PleaseWait : string,
|
||||
GameDraw : string
|
||||
}
|
||||
|
||||
export const EnUs: Texts = {
|
||||
@ -42,7 +43,8 @@ export const EnUs: Texts = {
|
||||
OpponentLeavesTheGame: "Opponent Leaves The Game",
|
||||
YouLeftTheGame: "You Left The Game",
|
||||
SearchingOpponent: "Searching Opponent",
|
||||
PleaseWait : "Please Wait"
|
||||
PleaseWait : "Please Wait",
|
||||
GameDraw : "Draw"
|
||||
}
|
||||
|
||||
export const TrTr: Texts = {
|
||||
@ -65,5 +67,6 @@ export const TrTr: Texts = {
|
||||
OpponentLeavesTheGame: "Rakip Oyundan Ayrıldı",
|
||||
YouLeftTheGame: "Sen Oyundan Ayrıldın",
|
||||
SearchingOpponent: "Rakip Aranıyor",
|
||||
PleaseWait: "Lütfen Bekleyin"
|
||||
PleaseWait: "Lütfen Bekleyin",
|
||||
GameDraw : "Berabere"
|
||||
}
|
||||
@ -128,10 +128,10 @@ export class Game {
|
||||
|
||||
//todo throw expection
|
||||
public getPlayerKeyByName(key: "player1" | "player2"): string {
|
||||
if (this.player1 == key) {
|
||||
return "player1"
|
||||
if (key == "player1") {
|
||||
return this.player1
|
||||
} else {
|
||||
return "player2"
|
||||
return this.player2
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,9 +144,9 @@ export class Game {
|
||||
const player2BallCount = this.board.player2Store.ballCount
|
||||
|
||||
if(player1BallCount < player2BallCount){
|
||||
return this.getPlayerKeyByName("player1")
|
||||
}else if(player1BallCount > player2BallCount) {
|
||||
return this.getPlayerKeyByName("player2")
|
||||
}else if(player1BallCount > player2BallCount) {
|
||||
return this.getPlayerKeyByName("player1")
|
||||
}else{
|
||||
return undefined
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user