issue-15 #21
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import {ScriptAccountCondition} from "../../../../src/app/game-model/gamesystems/conditions/ScriptAccountCondition";
|
||||||
|
import {ScriptAccount} from "../../../../src/app/game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import exp = require("node:constants");
|
||||||
|
import {ConditionTrainer} from "./ConditionTrainer";
|
||||||
|
test.describe('Test Expand Conditions', () => {
|
||||||
|
|
||||||
|
test("Test expansion with contradiccting Conditions", async () => {
|
||||||
|
const condition = ConditionTrainer.withSimpleCondition();
|
||||||
|
const otherCondition = ConditionTrainer.withContradictingCondition(condition);
|
||||||
|
|
||||||
|
condition.extendCondition(otherCondition)
|
||||||
|
expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue);
|
||||||
|
expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue);
|
||||||
|
})
|
||||||
|
|
||||||
|
test("Test lower expansion of Conditions", async () => {
|
||||||
|
const condition = ConditionTrainer.withSimpleCondition();
|
||||||
|
const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-10, condition.minValue+10)
|
||||||
|
|
||||||
|
condition.extendCondition(otherCondition);
|
||||||
|
expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue-10)
|
||||||
|
expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue);
|
||||||
|
})
|
||||||
|
|
||||||
|
test("Test higher expansion of conditions", async () => {
|
||||||
|
const condition = ConditionTrainer.withSimpleCondition();
|
||||||
|
const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.maxValue-10, condition.maxValue+10)
|
||||||
|
|
||||||
|
condition.extendCondition(otherCondition)
|
||||||
|
expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue)
|
||||||
|
expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue+10)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("Test higher and lower Expansion of Conditions", async () => {
|
||||||
|
const condition = ConditionTrainer.withSimpleCondition();
|
||||||
|
const otherCondition = ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-10, condition.maxValue+10);
|
||||||
|
|
||||||
|
condition.extendCondition(otherCondition);
|
||||||
|
expect(condition.minValue).toEqual(ConditionTrainer.withSimpleCondition().minValue-10)
|
||||||
|
expect(condition.maxValue).toEqual(ConditionTrainer.withSimpleCondition().maxValue+10)
|
||||||
|
})
|
||||||
|
});
|
@ -7,8 +7,7 @@ export class ConditionTrainer {
|
|||||||
return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10);
|
return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static withSimpleOtherCondition(): ScriptAccountCondition {
|
static withContradictingCondition(condition: ScriptAccountCondition): ScriptAccountCondition {
|
||||||
const scriptAccount = new ScriptAccount("Another Test", "");
|
return ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue-20, condition.minValue-10);
|
||||||
return ScriptAccountCondition.constructScriptAccountCondition(scriptAccount, 0, 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ export class ScriptAccountCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extendCondition(condition: ScriptAccountCondition) {
|
extendCondition(condition: ScriptAccountCondition) {
|
||||||
|
if(!this.isContradicting(condition)) {
|
||||||
|
this.minValue = Math.min(this.minValue, condition.minValue);
|
||||||
|
this.maxValue = Math.max(this.maxValue, condition.maxValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isContradicting(condition: ScriptAccountCondition) {
|
isContradicting(condition: ScriptAccountCondition) {
|
||||||
|
Loading…
Reference in New Issue
Block a user