feat: add new general actions for border return, gifting, disbanding, founding nations, and fierce training
- Implemented '접경귀환' action for returning to a home city within 3 spaces. - Added '증여' action for transferring resources between generals with constraints. - Created '해산' action to disband a faction, resetting generals and cities. - Developed '건국' action for founding a new nation with specified attributes. - Introduced '맹훈련' action for training generals, enhancing their stats. - Added tests for the new actions to ensure functionality and constraints are respected.
This commit is contained in:
@@ -51,6 +51,41 @@ export const occupiedCity = (options: { allowNeutral?: boolean } = {}): Constrai
|
||||
},
|
||||
});
|
||||
|
||||
export const notOccupiedCity = (): Constraint => ({
|
||||
name: 'notOccupiedCity',
|
||||
requires: (ctx) => {
|
||||
const reqs: RequirementKey[] = [{ kind: 'general', id: ctx.actorId }];
|
||||
if (ctx.cityId !== undefined) {
|
||||
reqs.push({ kind: 'city', id: ctx.cityId });
|
||||
}
|
||||
return reqs;
|
||||
},
|
||||
test: (ctx, view) => {
|
||||
const generalReq: RequirementKey = { kind: 'general', id: ctx.actorId };
|
||||
if (!view.has(generalReq)) {
|
||||
return unknownOrDeny(ctx, [generalReq], '장수 정보가 없습니다.');
|
||||
}
|
||||
const general = view.get(generalReq) as General | null;
|
||||
if (!general) {
|
||||
return unknownOrDeny(ctx, [generalReq], '장수 정보가 없습니다.');
|
||||
}
|
||||
|
||||
const cityId = ctx.cityId ?? general.cityId;
|
||||
const cityReq: RequirementKey = { kind: 'city', id: cityId };
|
||||
if (!view.has(cityReq)) {
|
||||
return unknownOrDeny(ctx, [cityReq], '도시 정보가 없습니다.');
|
||||
}
|
||||
const city = view.get(cityReq) as City | null;
|
||||
if (!city) {
|
||||
return unknownOrDeny(ctx, [cityReq], '도시 정보가 없습니다.');
|
||||
}
|
||||
if (city.nationId !== general.nationId) {
|
||||
return allow();
|
||||
}
|
||||
return { kind: 'deny', reason: '아국입니다.' };
|
||||
},
|
||||
});
|
||||
|
||||
export const occupiedDestCity = (): Constraint => ({
|
||||
name: 'occupiedDestCity',
|
||||
requires: (ctx) => {
|
||||
@@ -499,6 +534,8 @@ export const beNeutralCity = (): Constraint => ({
|
||||
},
|
||||
});
|
||||
|
||||
export const neutralCity = (): Constraint => beNeutralCity();
|
||||
|
||||
export const constructableCity = (): Constraint => ({
|
||||
name: 'constructableCity',
|
||||
requires: (ctx) => (ctx.cityId !== undefined ? [{ kind: 'city', id: ctx.cityId }] : []),
|
||||
|
||||
Reference in New Issue
Block a user