Skip to content

Commit

Permalink
Merge branch 'main' into ari/drawremotness
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncheung00 committed Nov 27, 2023
2 parents d022c7a + 42e1895 commit 7e0f227
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"axios": "0.27.2",
"axios": "1.6.0",
"gsap": "^3.11.3",
"lodash": "4.17.21",
"markdown-it-link-attributes": "4.0.0",
Expand Down
28 changes: 21 additions & 7 deletions src/components/units/GameBody/AppGameBodyStatisticsMessage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<div id="app-game-body-statistics-message" v-if="showNextMoveHints">
<!-- Game not over -->
<template v-if="currentRemoteness != 0">
<!-- Games: Special handling if current position is drawing -->
<p v-if="!isPuzzleGame && currentPositionValue === 'draw'">
<b class="uni-turn-1">{{ currentLeftPlayerName }}</b> and
<b class="uni-turn-2">{{ currentRightPlayerName }}</b> are in a
Expand All @@ -15,26 +17,35 @@
Draw Remoteness: <mark :class="`uni-${currentPositionValue}`"> {{currentDrawRemoteness}}</mark>
</span>
</p>
<!-- Games: Special handling if current position is unsolved -->
<p v-else-if="!isPuzzleGame && currentPositionValue === 'unsolved'">
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b>'s
turn. {{ mexStr }}
</p>
<!-- Games: win/lose/tie in <remoteness> moves -->
<p v-else-if="!isPuzzleGame">
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b> should
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b>
{{ currentPlayerIsComputer ? "will" : "should" }}
<mark :class="`uni-${currentPositionValue}`">{{ currentPositionValue }}</mark>
the game in {{ currentRemoteness }}
move<span v-if="currentRemoteness !== 1">s</span>. {{ mexStr }}
{{ currentRemoteness == 1 ? "move" : "moves" }}{{ currentWinBy ? " or by " + currentWinBy : "" }}.
{{ mexStr }}
</p>
<!-- Puzzles: solve the puzzle in <remoteness> moves -->
<p v-else>
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b> should
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b>
{{ currentPlayerIsComputer ? "will" : "should" }}
<mark :class="`uni-win`">solve</mark> the puzzle in {{ currentRemoteness }}
move<span v-if="currentRemoteness !== 1">s</span>.
</p>
{{ currentRemoteness == 1 ? "move" : "moves" }}.
</p>
</template>

<!-- Game over -->
<template v-else>
<p v-if="!isPuzzleGame && currentPositionValue === 'win'">
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b> has
<mark :class="`uni-${currentPositionValue}`">won</mark> the game! {{ mexStr }}
<mark :class="`uni-${currentPositionValue}`">won</mark>
the game{{ currentWinBy ? " by " + currentWinBy : "" }}! {{ mexStr }}
</p>
<p v-else-if="!isPuzzleGame && currentPositionValue === 'tie'">
<b class="uni-turn-1">{{ currentLeftPlayerName }}</b> and
Expand All @@ -43,7 +54,8 @@
</p>
<p v-else-if="!isPuzzleGame && currentPositionValue === 'lose'">
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b> has
<mark :class="`uni-${currentPositionValue}`">lost</mark> the game! {{ mexStr }}
<mark :class="`uni-${currentPositionValue}`">lost</mark>
the game{{ currentWinBy ? " by " + currentWinBy : "" }}! {{ mexStr }}
</p>
<p v-else-if="isPuzzleGame">
<b :class="`uni-turn-${currentTurn}`">{{ currentPlayerName }}</b> has
Expand All @@ -70,11 +82,13 @@
const currentLeftPlayerName = computed(() => store.getters.currentLeftPlayer.name);
const currentRightPlayerName = computed(() => store.getters.currentRightPlayer.name);
const currentPlayerName = computed(() => (store.getters.currentPlayer ? store.getters.currentPlayer.name : ""));
const currentPlayerIsComputer = computed(() => (store.getters.currentPlayer ? store.getters.currentPlayer.isComputer : false));
const currentRemoteness = computed(() => store.getters.currentRemoteness);
const currentPositionValue = computed(() => store.getters.currentPositionValue);
const currentDrawValue = computed(() => store.getters.currentPositionDrawRemoteness % 2 == 0 ? "lose": "win");
const currentDrawRemoteness = computed(() => store.getters.currentPositionDrawRemoteness);
const currentDrawLevel = computed(() => store.getters.currentPositionDrawLevel);
const currentWinBy = computed(() => store.getters.currentWinBy);
const mexStr = computed(() => (store.getters.currentPositionMex !== "") ? "[Grundy #: " + store.getters.currentPositionMex + "]" : "");
</script>

Expand Down
86 changes: 81 additions & 5 deletions src/components/units/GameBody/ImageAutoGUI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@
:d="formatArrowPolylinePoints(arrow, arrowWidth)"
:class="'app-game-board-default-arrow ' + getBoardMoveElementHintClass(arrow.move)"
:opacity="options.showNextMoveHints && options.showNextMoveDeltaRemotenesses ? arrow.move.hintOpacity : 1"
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: arrow.move.str })"/>
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: arrow.move.str })">
<title>
{{
!options.showNextMoveHints ? "" : (
arrow.move.value + (
arrow.move.value === "draw" || arrow.move.value === "unsolved" ? "" : (
" in " + arrow.move.remoteness + (
!arrow.move.winby ? "" : " by " + arrow.move.winby
)
)
)
)
}}
</title>
</path>
</g>
</g>

Expand Down Expand Up @@ -51,7 +65,21 @@
:class="'app-game-board-default-button ' + (token.move ? 'move ' : '') + getBoardMoveElementHintClass(token.move)"
:opacity="options.showNextMoveHints && options.showNextMoveDeltaRemotenesses ? token.move.hintOpacity : 1"
:style="'--tOrigin: ' + centers[token.to][0] + 'px ' + centers[token.to][1] + 'px;'"
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: token.move.str })"/>
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: token.move.str })">
<title>
{{
!options.showNextMoveHints ? "" : (
token.move.value + (
token.move.value === "draw" || token.move.value === "unsolved" ? "" : (
" in " + token.move.remoteness + (
!token.move.winby ? "" : " by " + token.move.winby
)
)
)
)
}}
</title>
</circle>

<!-- Else use the svg corresponding to the move token. If no svg is mapped to the character, skip. -->
<g v-else-if="token.token in entities">
Expand All @@ -71,7 +99,21 @@
:class="'app-game-board-default-button ' + (token.move ? 'move ' : '') + getBoardMoveElementHintClass(token.move)"
:opacity="options.showNextMoveHints && options.showNextMoveDeltaRemotenesses ? token.move.hintOpacity : 1"
:style="'--tOrigin: ' + centers[token.to][0] + 'px ' + centers[token.to][1] + 'px;mask: url(#svgmask' + i + ');'"
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: token.move.str })"/>
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: token.move.str })">
<title>
{{
!options.showNextMoveHints ? "" : (
token.move.value + (
token.move.value === "draw" || token.move.value === "unsolved" ? "" : (
" in " + token.move.remoteness + (
!token.move.winby ? "" : " by " + token.move.winby
)
)
)
)
}}
</title>
</rect>
</g>
</g>
</g>
Expand All @@ -83,7 +125,21 @@
:d="formatArrowPolylinePoints(arrow, arrowWidth)"
:class="'app-game-board-default-arrow ' + getBoardMoveElementHintClass(arrow.move)"
:opacity="options.showNextMoveHints && options.showNextMoveDeltaRemotenesses ? arrow.move.hintOpacity : 1"
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: arrow.move.str })"/>
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: arrow.move.str })">
<title>
{{
!options.showNextMoveHints ? "" : (
arrow.move.value + (
arrow.move.value === "draw" || arrow.move.value === "unsolved" ? "" : (
" in " + arrow.move.remoteness + (
!arrow.move.winby ? "" : " by " + arrow.move.winby
)
)
)
)
}}
</title>
</path>
</g>
</g>

Expand All @@ -99,7 +155,21 @@
:stroke-width="lineWidth * widthFactor"
:class="'app-game-board-default-line ' + getBoardMoveElementHintClass(line.move)"
:opacity="options.showNextMoveHints && options.showNextMoveDeltaRemotenesses ? line.move.hintOpacity : 1"
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: line.move.str })"/>
@click="!isComputerTurn && store.dispatch(actionTypes.runMove, { move: line.move.str })">
<title>
{{
!options.showNextMoveHints ? "" : (
line.move.value + (
line.move.value === "draw" || line.move.value === "unsolved" ? "" : (
" in " + line.move.remoteness + (
!line.move.winby ? "" : " by " + line.move.winby
)
)
)
)
}}
</title>
</line>
</g>
</g>
</svg>
Expand All @@ -112,6 +182,9 @@
interface GDefaultRegular2DMove {
str: string; // UWAPI move string
value: string;
remoteness: number;
winby: number;
hint: string;
hintOpacity: number;
nextPosition: string;
Expand Down Expand Up @@ -181,7 +254,10 @@
for (let nextMoveData of Object.values(currentAvailableMoves.value)) {
const move = {
str: nextMoveData.move,
value: nextMoveData.moveValue,
hint: nextMoveData.moveValue,
remoteness: nextMoveData.remoteness,
winby: nextMoveData.winby,
hintOpacity: !options.value.showNextMoves ? 0.001 : nextMoveData.moveValueOpacity,
nextPosition: nextMoveData.position
};
Expand Down
4 changes: 3 additions & 1 deletion src/models/datas/defaultApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export const defaultMatch: Types.Match = {
animationPlaying: false
};

export const defaultCPUsStrategy: Array<string> = ["Remoteness", "Remoteness"];

export const defaultApp: Types.App = {
...defaultUpdate,
version: <string>import.meta.env.PACKAGE_VERSION || "",
Expand Down Expand Up @@ -185,5 +187,5 @@ export const defaultApp: Types.App = {
backgroundLoading: false,
computerMoving: false
},
CPUsStrategy: ["Remoteness", "Remoteness"],
CPUsStrategy: defaultCPUsStrategy,
};
1 change: 1 addition & 0 deletions src/scripts/gamesmanUni/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export const initiateMatch = async (app: Types.App, payload: {
const updatedApp = await loadPosition(app, { ...payload, position: startPosition });
if (!updatedApp) return undefined;

if (!game.supportsWinBy) app.CPUsStrategy = Defaults.defaultCPUsStrategy;
app.currentMatch.gameTheme = gameVariant.imageAutoGUIData ? gameVariant.imageAutoGUIData.defaultTheme : "";
app.currentMatch.startPosition = startPosition;
app.currentMatch.moveHistory = game.name + moveHistoryDelim + startPosition;
Expand Down
28 changes: 18 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2177,13 +2177,14 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:0.27.2":
version: 0.27.2
resolution: "axios@npm:0.27.2"
"axios@npm:1.6.0":
version: 1.6.0
resolution: "axios@npm:1.6.0"
dependencies:
follow-redirects: ^1.14.9
follow-redirects: ^1.15.0
form-data: ^4.0.0
checksum: 38cb7540465fe8c4102850c4368053c21683af85c5fdf0ea619f9628abbcb59415d1e22ebc8a6390d2bbc9b58a9806c874f139767389c862ec9b772235f06854
proxy-from-env: ^1.1.0
checksum: c7c9f2ae9e0b9bad7d6f9a4dff030930b12ee667dedf54c3c776714f91681feb743c509ac0796ae5c01e12c4ab4a2bee74905068dd200fbc1ab86f9814578fb0
languageName: node
linkType: hard

Expand Down Expand Up @@ -3231,13 +3232,13 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.14.9":
version: 1.15.1
resolution: "follow-redirects@npm:1.15.1"
"follow-redirects@npm:^1.15.0":
version: 1.15.3
resolution: "follow-redirects@npm:1.15.3"
peerDependenciesMeta:
debug:
optional: true
checksum: 6aa4e3e3cdfa3b9314801a1cd192ba756a53479d9d8cca65bf4db3a3e8834e62139245cd2f9566147c8dfe2efff1700d3e6aefd103de4004a7b99985e71dd533
checksum: 584da22ec5420c837bd096559ebfb8fe69d82512d5585004e36a3b4a6ef6d5905780e0c74508c7b72f907d1fa2b7bd339e613859e9c304d0dc96af2027fd0231
languageName: node
linkType: hard

Expand Down Expand Up @@ -3351,7 +3352,7 @@ __metadata:
"@vitejs/plugin-legacy": 1.8.2
"@vitejs/plugin-vue": 2.3.3
"@vue/compiler-sfc": 3.2.37
axios: 0.27.2
axios: 1.6.0
gsap: ^3.11.3
https-localhost: 4.7.1
lodash: 4.17.21
Expand Down Expand Up @@ -4743,6 +4744,13 @@ __metadata:
languageName: node
linkType: hard

"proxy-from-env@npm:^1.1.0":
version: 1.1.0
resolution: "proxy-from-env@npm:1.1.0"
checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4
languageName: node
linkType: hard

"pseudomap@npm:^1.0.2":
version: 1.0.2
resolution: "pseudomap@npm:1.0.2"
Expand Down

0 comments on commit 7e0f227

Please sign in to comment.