Changed all occurrences of 'yahtzee' to 'superkadi', allowed the gameboards to be hydrated by JSON data upon instantiation (also after).
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
import { FieldType } from "./enums";
|
||||
export enum FieldType {
|
||||
number = "numberField",
|
||||
bool = "boolField",
|
||||
bonus = "bonusField",
|
||||
subtotal = "subtotalField",
|
||||
globalTotal = "globalTotalField",
|
||||
total = "totalField",
|
||||
superkadi = "superkadiField",
|
||||
multiplier = "multiplierField",
|
||||
}
|
||||
|
||||
export const defaultCellValues = {
|
||||
[FieldType.number]: 0,
|
||||
@@ -6,12 +15,11 @@ export const defaultCellValues = {
|
||||
[FieldType.subtotal]: 0,
|
||||
[FieldType.total]: 0,
|
||||
[FieldType.bonus]: 0,
|
||||
[FieldType.yahtzee]: 0,
|
||||
[FieldType.superkadi]: 0,
|
||||
[FieldType.multiplier]: 0,
|
||||
};
|
||||
|
||||
// ----- gameSchema interface definitions
|
||||
export interface GameSchema {
|
||||
export interface Ruleset {
|
||||
id: string;
|
||||
label: string;
|
||||
blocks: Record<string, BlockDef>;
|
||||
@@ -35,10 +43,10 @@ interface DefaultBlockDef {
|
||||
}
|
||||
|
||||
export type CellDef =
|
||||
| BoolCellDef
|
||||
| MultiplierCellDef
|
||||
| NumberCellDef
|
||||
| YahtzeeCellDef;
|
||||
| BoolCellDef
|
||||
| MultiplierCellDef
|
||||
| NumberCellDef
|
||||
| SuperkadiCellDef;
|
||||
|
||||
export interface BoolCellDef extends DefaultCellDef {
|
||||
fieldType: FieldType.bool;
|
||||
@@ -51,10 +59,10 @@ export interface MultiplierCellDef extends DefaultCellDef {
|
||||
maxMultiples: number;
|
||||
}
|
||||
|
||||
export interface YahtzeeCellDef extends DefaultCellDef {
|
||||
fieldType: FieldType.yahtzee;
|
||||
export interface SuperkadiCellDef extends DefaultCellDef {
|
||||
fieldType: FieldType.superkadi;
|
||||
score: number;
|
||||
maxYahtzees: number;
|
||||
maxSuperkadis: number;
|
||||
}
|
||||
|
||||
export interface NumberCellDef extends DefaultCellDef {
|
||||
@@ -65,11 +73,12 @@ interface DefaultCellDef {
|
||||
label: string;
|
||||
}
|
||||
|
||||
|
||||
// ----- Predefined sets
|
||||
const defaultDiceCount = 5;
|
||||
const DEFAULT_RULESET = "DEFAULT_RULESET";
|
||||
|
||||
const gameSchemas: GameSchema[] = [
|
||||
const gameSchemas: Ruleset[] = [
|
||||
{
|
||||
id: DEFAULT_RULESET,
|
||||
label: "Standard Kadi Rules (en)",
|
||||
@@ -127,39 +136,39 @@ const gameSchemas: GameSchema[] = [
|
||||
label: "Lower",
|
||||
hasBonus: false,
|
||||
cells: {
|
||||
three_kind: {
|
||||
threeKind: {
|
||||
fieldType: FieldType.number,
|
||||
label: "Three of a Kind",
|
||||
},
|
||||
|
||||
four_kind: {
|
||||
fourKind: {
|
||||
fieldType: FieldType.number,
|
||||
label: "Four of a Kind",
|
||||
},
|
||||
|
||||
full_house: {
|
||||
fullHouse: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Full House",
|
||||
score: 25,
|
||||
},
|
||||
|
||||
sml_straight: {
|
||||
smlStraight: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Small Straight",
|
||||
score: 30,
|
||||
},
|
||||
|
||||
lg_straight: {
|
||||
lgSraight: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Large Straight",
|
||||
score: 40,
|
||||
},
|
||||
|
||||
yahtzee: {
|
||||
fieldType: FieldType.yahtzee,
|
||||
label: "Kadi",
|
||||
kadi: {
|
||||
fieldType: FieldType.superkadi,
|
||||
label: "Super Kadis",
|
||||
score: 50,
|
||||
maxYahtzees: 5,
|
||||
maxSuperkadis: 5,
|
||||
},
|
||||
|
||||
chance: {
|
||||
@@ -227,34 +236,34 @@ const gameSchemas: GameSchema[] = [
|
||||
label: "Unten",
|
||||
hasBonus: false,
|
||||
cells: {
|
||||
three_kind: {
|
||||
threeKind: {
|
||||
fieldType: FieldType.number,
|
||||
label: "Dreierpasch",
|
||||
},
|
||||
four_kind: {
|
||||
fourKind: {
|
||||
fieldType: FieldType.number,
|
||||
label: "Viererpasch",
|
||||
},
|
||||
full_house: {
|
||||
fullSouse: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Full House",
|
||||
score: 25,
|
||||
},
|
||||
sml_straight: {
|
||||
smlStraight: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Kleine Straße",
|
||||
score: 30,
|
||||
},
|
||||
lg_straight: {
|
||||
lgStraight: {
|
||||
fieldType: FieldType.bool,
|
||||
label: "Große Straße",
|
||||
score: 40,
|
||||
},
|
||||
yahtzee: {
|
||||
fieldType: FieldType.yahtzee,
|
||||
label: "Kadi",
|
||||
kadi: {
|
||||
fieldType: FieldType.superkadi,
|
||||
label: "Ultrakadi",
|
||||
score: 50,
|
||||
maxYahtzees: 5,
|
||||
maxSuperkadis: 5,
|
||||
},
|
||||
change: {
|
||||
fieldType: FieldType.number,
|
||||
@@ -266,7 +275,7 @@ const gameSchemas: GameSchema[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export function getGameSchemaById(schemaId: string): GameSchema {
|
||||
export function getGameSchemaById(schemaId: string): Ruleset {
|
||||
for (const schema of gameSchemas) {
|
||||
if (schema.id === schemaId) {
|
||||
return schema;
|
||||
|
||||
Reference in New Issue
Block a user