mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-24 19:44:05 +02:00
wip
This commit is contained in:
@@ -324,3 +324,39 @@ export function calcOwnedDoraCount(handTiles: Tile[], huros: Huro[], doras: Tile
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
export function calcTsumoHoraPointDeltas(house: House, fans: number): Record<House, number> {
|
||||
const isParent = house === 'e';
|
||||
|
||||
const deltas: Record<House, number> = {
|
||||
e: 0,
|
||||
s: 0,
|
||||
w: 0,
|
||||
n: 0,
|
||||
};
|
||||
|
||||
const point = fanToPoint(fans, isParent);
|
||||
deltas[house] = point;
|
||||
if (isParent) {
|
||||
const childPoint = Math.ceil(point / 3);
|
||||
deltas.s = -childPoint;
|
||||
deltas.w = -childPoint;
|
||||
deltas.n = -childPoint;
|
||||
} else {
|
||||
const parentPoint = Math.ceil(point / 2);
|
||||
deltas.e = -parentPoint;
|
||||
const otherPoint = Math.ceil(point / 4);
|
||||
if (house === 's') {
|
||||
deltas.w = -otherPoint;
|
||||
deltas.n = -otherPoint;
|
||||
} else if (house === 'w') {
|
||||
deltas.s = -otherPoint;
|
||||
deltas.n = -otherPoint;
|
||||
} else if (house === 'n') {
|
||||
deltas.s = -otherPoint;
|
||||
deltas.w = -otherPoint;
|
||||
}
|
||||
}
|
||||
|
||||
return deltas;
|
||||
}
|
||||
|
||||
@@ -230,11 +230,11 @@ export class MasterGameEngine {
|
||||
}
|
||||
|
||||
/**
|
||||
* ロン
|
||||
* ロン和了
|
||||
* @param callers ロンする人
|
||||
* @param callee ロンされる人
|
||||
*/
|
||||
private ron(callers: House[], callee: House) {
|
||||
private ronHora(callers: House[], callee: House) {
|
||||
for (const house of callers) {
|
||||
const yakus = YAKU_DEFINITIONS.filter(yaku => yaku.calc({
|
||||
house: house,
|
||||
@@ -383,11 +383,9 @@ export class MasterGameEngine {
|
||||
* ツモ和了
|
||||
* @param house
|
||||
*/
|
||||
public commit_hora(house: House) {
|
||||
public commit_tsumoHora(house: House) {
|
||||
if (this.state.turn !== house) throw new Error('Not your turn');
|
||||
|
||||
const isParent = house === 'e';
|
||||
|
||||
const yakus = YAKU_DEFINITIONS.filter(yaku => yaku.calc({
|
||||
house: house,
|
||||
handTiles: this.state.handTiles[house],
|
||||
@@ -398,29 +396,11 @@ export class MasterGameEngine {
|
||||
}));
|
||||
const doraCount = Common.calcOwnedDoraCount(this.state.handTiles[house], this.state.huros[house], this.doras);
|
||||
const fans = yakus.map(yaku => yaku.fan).reduce((a, b) => a + b, 0) + doraCount;
|
||||
const point = Common.fanToPoint(fans, isParent);
|
||||
this.state.points[house] += point;
|
||||
if (isParent) {
|
||||
const childPoint = Math.ceil(point / 3);
|
||||
this.state.points.s -= childPoint;
|
||||
this.state.points.w -= childPoint;
|
||||
this.state.points.n -= childPoint;
|
||||
} else {
|
||||
const parentPoint = Math.ceil(point / 2);
|
||||
this.state.points.e -= parentPoint;
|
||||
const otherPoint = Math.ceil(point / 4);
|
||||
if (house === 's') {
|
||||
this.state.points.w -= otherPoint;
|
||||
this.state.points.n -= otherPoint;
|
||||
} else if (house === 'w') {
|
||||
this.state.points.s -= otherPoint;
|
||||
this.state.points.n -= otherPoint;
|
||||
} else if (house === 'n') {
|
||||
this.state.points.s -= otherPoint;
|
||||
this.state.points.w -= otherPoint;
|
||||
}
|
||||
}
|
||||
console.log('fans point', fans, point);
|
||||
const pointDeltas = Common.calcTsumoHoraPointDeltas(house, fans);
|
||||
this.state.points.e += pointDeltas.e;
|
||||
this.state.points.s += pointDeltas.s;
|
||||
this.state.points.w += pointDeltas.w;
|
||||
this.state.points.n += pointDeltas.n;
|
||||
console.log('yakus', house, yakus);
|
||||
|
||||
this.endKyoku();
|
||||
@@ -445,7 +425,7 @@ export class MasterGameEngine {
|
||||
this.state.ronAsking = null;
|
||||
|
||||
if (ron != null && answers.ron.length > 0) {
|
||||
this.ron(answers.ron, ron.callee);
|
||||
this.ronHora(answers.ron, ron.callee);
|
||||
return {
|
||||
type: 'ronned' as const,
|
||||
callers: ron.callers,
|
||||
|
||||
@@ -146,8 +146,8 @@ export class PlayerGameEngine {
|
||||
if (this.state.turn !== house) throw new PlayerGameEngine.InvalidOperationError();
|
||||
}
|
||||
|
||||
public commit_hora(house: House) {
|
||||
console.log('commit_hora', this.state.turn, house);
|
||||
public commit_tsumoHora(house: House) {
|
||||
console.log('commit_tsumoHora', this.state.turn, house);
|
||||
|
||||
// TODO: ツモした人の手牌情報を貰う必要がある
|
||||
}
|
||||
@@ -157,13 +157,13 @@ export class PlayerGameEngine {
|
||||
* @param callers ロンした人
|
||||
* @param callee 牌を捨てた人
|
||||
*/
|
||||
public commit_ron(callers: House[], callee: House, handTiles: {
|
||||
public commit_ronHora(callers: House[], callee: House, handTiles: {
|
||||
e: Tile[];
|
||||
s: Tile[];
|
||||
w: Tile[];
|
||||
n: Tile[];
|
||||
}) {
|
||||
console.log('commit_ron', this.state.turn, callers, callee);
|
||||
console.log('commit_ronHora', this.state.turn, callers, callee);
|
||||
|
||||
this.state.canRonSource = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user