player can chii(l?)
This commit is contained in:
parent
ac2825a7cb
commit
317624bd57
3 changed files with 54 additions and 17 deletions
|
|
@ -88,7 +88,7 @@ export function clickChii(
|
||||||
r > 10 &&
|
r > 10 &&
|
||||||
inside
|
inside
|
||||||
) {
|
) {
|
||||||
return q === chiis.length ? 0 : q + 1;
|
return q === chiis.length ? 0 : chiis[q][0].getValue();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +97,7 @@ export function drawChiis(
|
||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
chiis: Array<Array<Tile>>
|
chiis: Array<Array<Tile>>
|
||||||
): void {
|
): void {
|
||||||
|
chiis.reverse();
|
||||||
const r = 8;
|
const r = 8;
|
||||||
const w = 110;
|
const w = 110;
|
||||||
const h = 50;
|
const h = 50;
|
||||||
|
|
@ -106,9 +107,7 @@ export function drawChiis(
|
||||||
ctx.fillText("Retour", 850 + w * 0.1, 835 + h/2 * 1.3);
|
ctx.fillText("Retour", 850 + w * 0.1, 835 + h/2 * 1.3);
|
||||||
|
|
||||||
let dx = 1;
|
let dx = 1;
|
||||||
console.log("length: ", chiis.length, "\n");
|
|
||||||
for (let i = 0; i < chiis.length; i++) {
|
for (let i = 0; i < chiis.length; i++) {
|
||||||
console.log("trying to draw\n");
|
|
||||||
drawOneChii(
|
drawOneChii(
|
||||||
ctx,
|
ctx,
|
||||||
850 - dx * 120,
|
850 - dx * 120,
|
||||||
|
|
@ -128,9 +127,40 @@ function drawOneChii(
|
||||||
const r = 8;
|
const r = 8;
|
||||||
const w = 110;
|
const w = 110;
|
||||||
const h = 50;
|
const h = 50;
|
||||||
|
const dx = 32;
|
||||||
|
const x0 = x + 7;
|
||||||
|
const y0 = y + 5;
|
||||||
button(ctx, x, y, r, w, h, "#FFCC33");
|
button(ctx, x, y, r, w, h, "#FFCC33");
|
||||||
ctx.fillStyle = "black";
|
tiles[0].drawTile(
|
||||||
ctx.font = "30px garamond";
|
ctx,
|
||||||
|
x0,
|
||||||
|
y0,
|
||||||
|
0.4,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
tiles[1].drawTile(
|
||||||
|
ctx,
|
||||||
|
x0 + dx,
|
||||||
|
y0,
|
||||||
|
0.4,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
tiles[2].drawTile(
|
||||||
|
ctx,
|
||||||
|
x0 + 2 * dx,
|
||||||
|
y0,
|
||||||
|
0.4,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function button(
|
function button(
|
||||||
|
|
|
||||||
24
src/game.ts
24
src/game.ts
|
|
@ -109,10 +109,11 @@ export class Game {
|
||||||
mp.y - rect.y,
|
mp.y - rect.y,
|
||||||
allChii
|
allChii
|
||||||
);
|
);
|
||||||
console.log("chii action:", c, "\n");
|
|
||||||
|
|
||||||
if (c === 0) {
|
if (c === 0) {
|
||||||
this.chooseChii = false;
|
this.chooseChii = false;
|
||||||
|
} else {
|
||||||
|
this.chooseChii = false;
|
||||||
|
this.chii(c, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let action = clickAction(
|
let action = clickAction(
|
||||||
|
|
@ -138,8 +139,8 @@ export class Game {
|
||||||
this.hasPlayed = false;
|
this.hasPlayed = false;
|
||||||
} else if (action === 1) { // chii
|
} else if (action === 1) { // chii
|
||||||
let chiis = this.canDoAChii();
|
let chiis = this.canDoAChii();
|
||||||
if (chiis.length === 0) { // only one possible
|
if (chiis.length === 1) { // only one possible
|
||||||
this.chii(chiis[0], 0); // TODO not 0
|
this.chii(chiis[0], 0);
|
||||||
} else {
|
} else {
|
||||||
this.chooseChii = true;
|
this.chooseChii = true;
|
||||||
this.drawGame();
|
this.drawGame();
|
||||||
|
|
@ -250,18 +251,21 @@ export class Game {
|
||||||
h.count(t.getFamily(), t.getValue()-1) > 0
|
h.count(t.getFamily(), t.getValue()-1) > 0
|
||||||
) {
|
) {
|
||||||
chii.push(t.getValue()-2);
|
chii.push(t.getValue()-2);
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
h.count(t.getFamily(), t.getValue()-1) > 0 &&
|
h.count(t.getFamily(), t.getValue()-1) > 0 &&
|
||||||
h.count(t.getFamily(), t.getValue()+1) > 0
|
h.count(t.getFamily(), t.getValue()+1) > 0
|
||||||
) {
|
) {
|
||||||
chii.push(t.getValue()-1);
|
chii.push(t.getValue()-1);
|
||||||
} else if (
|
}
|
||||||
|
if (
|
||||||
h.count(t.getFamily(), t.getValue()+1) > 0 &&
|
h.count(t.getFamily(), t.getValue()+1) > 0 &&
|
||||||
h.count(t.getFamily(), t.getValue()+2) > 0
|
h.count(t.getFamily(), t.getValue()+2) > 0
|
||||||
) {
|
) {
|
||||||
chii.push(t.getValue());
|
chii.push(t.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(chii, "\n");
|
||||||
return chii;
|
return chii;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,11 +309,11 @@ export class Game {
|
||||||
let tt = this.hands[p].find(t.getFamily(), v + dv) as NonNullable<Tile>;
|
let tt = this.hands[p].find(t.getFamily(), v + dv) as NonNullable<Tile>;
|
||||||
chii.push(tt);
|
chii.push(tt);
|
||||||
this.hands[p].push(tt);
|
this.hands[p].push(tt);
|
||||||
|
this.hands[p].sort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chiis.push(chii);
|
chiis.push(chii);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chiis;
|
return chiis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,7 +409,7 @@ export class Game {
|
||||||
5 * this.sizeHiddenHand,
|
5 * this.sizeHiddenHand,
|
||||||
this.sizeHiddenHand,
|
this.sizeHiddenHand,
|
||||||
undefined,
|
undefined,
|
||||||
false,
|
true,
|
||||||
- pi / 2
|
- pi / 2
|
||||||
);
|
);
|
||||||
this.hands[2].drawHand(
|
this.hands[2].drawHand(
|
||||||
|
|
@ -415,7 +419,7 @@ export class Game {
|
||||||
5 * this.sizeHiddenHand,
|
5 * this.sizeHiddenHand,
|
||||||
this.sizeHiddenHand,
|
this.sizeHiddenHand,
|
||||||
undefined,
|
undefined,
|
||||||
false,
|
true,
|
||||||
- pi
|
- pi
|
||||||
);
|
);
|
||||||
this.hands[3].drawHand(
|
this.hands[3].drawHand(
|
||||||
|
|
@ -425,7 +429,7 @@ export class Game {
|
||||||
5 * this.sizeHiddenHand,
|
5 * this.sizeHiddenHand,
|
||||||
this.sizeHiddenHand,
|
this.sizeHiddenHand,
|
||||||
undefined,
|
undefined,
|
||||||
false,
|
true,
|
||||||
pi / 2
|
pi / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,14 @@ export class Tile {
|
||||||
size: number,
|
size: number,
|
||||||
hidden: boolean = false,
|
hidden: boolean = false,
|
||||||
rotation: number = 0,
|
rotation: number = 0,
|
||||||
gray: boolean = false
|
gray: boolean = false,
|
||||||
|
tilted: boolean = true
|
||||||
): void {
|
): void {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(x + (75 * size) / 2, y + (100 * size) / 2);
|
ctx.translate(x + (75 * size) / 2, y + (100 * size) / 2);
|
||||||
ctx.rotate(rotation + this.tilt);
|
if (tilted) {
|
||||||
|
ctx.rotate(rotation + this.tilt);
|
||||||
|
}
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue