Created
July 23, 2020 03:37
-
-
Save RoxDevvv/67542fd854f73a9c4f3b4e2792704ae5 to your computer and use it in GitHub Desktop.
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
init() { | |
/* | |
* mean safe place but not start place | |
Board[1] == safe place // entry of first player | |
Board[9] == safe place * | |
Board[14] == safe place // entry of second player | |
Board[22] == safe place * | |
Board[27] == safe place // entry of Third player | |
Board[35] == safe place * | |
Board[40] == safe place // entry of fourth player | |
Board[48] == safe place * | |
*/ | |
for (let index = 0; index < 52; index++) { // make the board of where all player moving and can meeting | |
const Board = new board(); | |
// full with regular places | |
if (index != 9 && index != 22 && index != 35 && index != 48 && index != 1 && index != 14 && index != 27 && index != 40) { | |
Board.Safe = false; | |
Board.PawnID = ""; | |
Board.StartPoint = ""; | |
this.state.Board.push(Board); | |
} | |
// full with safe places | |
if (index == 9 || index == 22 || index == 35 || index == 48) { | |
Board.Safe = true; | |
Board.PawnID = ""; | |
Board.StartPoint = ""; | |
this.state.Board.push(Board); | |
} | |
// full with safe places + start places (for each player have a start place) | |
if (index == 1) { | |
//P1 Start place of player 1 | |
Board.Safe = true; | |
Board.PawnID = ""; | |
Board.StartPoint = "P1"; | |
this.state.Board.push(Board); | |
} | |
else if (index == 14) { | |
//P2 Start place of player 1 | |
Board.Safe = true; | |
Board.PawnID = ""; | |
Board.StartPoint = "P2"; | |
this.state.Board.push(Board); | |
} | |
else if (index == 27) { | |
//P3 Start place of player 1 | |
Board.Safe = true; | |
Board.PawnID = ""; | |
Board.StartPoint = "P3"; | |
this.state.Board.push(Board); | |
} | |
else if (index == 40) { | |
//P4 Start place of player 1 | |
Board.Safe = true; | |
Board.PawnID = ""; | |
Board.StartPoint = "P4"; | |
this.state.Board.push(Board); | |
} | |
} | |
// full the plus area the last places of winning for each player | |
for (let index = 0; index < 6; index++) { | |
//player 1 plus area | |
var plus = new plusboard(); | |
plus.PID = "P1"; | |
plus.PawnID = ""; | |
this.state.PlusBoard.push(plus); | |
//player 2 plus area | |
plus = new plusboard(); | |
plus.PID = "P2"; | |
plus.PawnID = ""; | |
this.state.PlusBoard.push(plus); | |
//player 3 plus area | |
plus = new plusboard(); | |
plus.PID = "P3"; | |
plus.PawnID = ""; | |
this.state.PlusBoard.push(plus); | |
//player 4 plus area | |
plus = new plusboard(); | |
plus.PID = "P4"; | |
plus.PawnID = ""; | |
this.state.PlusBoard.push(plus); | |
} | |
this.state.PlusBoard.sort(function (a, b) { | |
return a.PID.localeCompare(b.PID); | |
}); | |
console.log("my dice chance : " + this.Chance()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment