Unify XP progression and enable ability ranks
This commit is contained in:
@@ -27,7 +27,7 @@ function craftingList(){
|
||||
list.append(button('Create recipe',()=>recipeForm()));
|
||||
for(const r of c.recipes){const d=node('details','','catalog-definition');d.append(node('summary',`${r.name} · revision ${r.revision}`),node('p',`${c.professions.find(p=>p.id===r.profession)?.name??r.profession} · difficulty ${r.level} · ${r.xp} XP on success`),readableDefinition(r),button('Edit recipe',()=>recipeForm(r)));list.append(d);}
|
||||
}else if(section==='craft-professions'){
|
||||
list.append(button('Create crafting profession',()=>{if(editing||saving)return;const identityFields=identity(),base=number(100,1,1000000,'1'),per=number(50,1,1000000,'1'),max=number(1000,1,1000,'1');const fields=form('Create crafting profession','create-craft-profession',()=>({craftProfession:{...identityFields.read(),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:Number(max.value)}}));fields.append(identityFields.node,field('First level XP',base),field('Additional XP per level',per),field('Maximum level',max));}));
|
||||
list.append(button('Create crafting profession',()=>{if(editing||saving)return;const identityFields=identity(),base=number(100,1,1000000,'1'),per=number(50,1,1000000,'1'),max=number(1000,1,1000,'1');const fields=form('Create crafting profession','create-craft-profession',()=>({craftProfession:{...identityFields.read(),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:Number(max.value)}}));fields.append(identityFields.node,node('p','XP to reach level L: 100 + 10 × (L - 2)².'),field('Maximum level',max));}));
|
||||
for(const p of c.professions){const d=node('details','','catalog-definition');d.append(node('summary',p.name),readableDefinition(p));list.append(d);}
|
||||
}else if(section==='craft-materials'){
|
||||
list.append(node('p','Stackable components for recipes. Food, traps, and building components do not gain action effects from their name alone.','muted'),button('Create crafting material',()=>{if(editing||saving)return;const values=identity();form('Create crafting material','create-craft-material',()=>({craftMaterial:values.read()})).append(values.node);}));
|
||||
@@ -148,7 +148,7 @@ function render(){
|
||||
}else if(section==='titles'){
|
||||
list.append(button('Create title',titleForm));for(const t of catalog.titles??[]){const d=node('details','','catalog-definition');d.append(node('summary',t.name),node('p',`${t.id} · ${t.scope} · ${t.description}`),node('p',(t.requirements??[]).map(r=>`${statLabel(r.metric)} ≥ ${r.atLeast}`).join(' / ')),modifiersView(t.effects.modifiers));if(t.effects.damage||t.effects.moveSpeed)d.append(node('p',`Damage ${t.effects.damage}; movement ${t.effects.moveSpeed}`));list.append(d);}
|
||||
}else if(section==='items'){
|
||||
list.append(button('Create equipment',itemForm));for(const i of catalog.items??[]){const d=node('details','','catalog-definition');d.append(node('summary',i.name),node('p',`${i.id} · ${statLabel(i.slot)} · Weight ${i.weight} · Drop chance ${i.dropChance??0}%`),node('p',i.description),node('p',`Requires level ${i.requirements.level}; ${Object.entries(i.requirements.stats??{}).map(([k,v])=>`${statLabel(k)} ${v}`).join(', ')} ${(i.requirements.titles??[]).map(id=>`Title: ${catalog.titles.find(t=>t.id===id)?.name??id}`).join(', ')}`),modifiersView(i.modifiers),node('p',`${i.craftRolls??0} crafted stat rolls`),readableDefinition(i.craftPool??[]));if(i.furniture)d.append(node('p',`House furniture · ${i.furniture.width} × ${i.furniture.depth}m · ${i.furniture.container?'Storage container':'Decoration'}`));list.append(d);}
|
||||
list.append(button('Create equipment',itemForm));for(const i of catalog.items??[]){const d=node('details','','catalog-definition');d.append(node('summary',i.name),node('p',`${i.id} · ${statLabel(i.slot)} · Weight ${i.weight} · Drop chance ${i.dropChance??0}%`),node('p',i.description),node('p',`Requires level ${i.requirements.level}; ${Object.entries(i.requirements.stats??{}).map(([k,v])=>`${statLabel(k)} ${v}`).join(', ')} ${(i.requirements.titles??[]).map(id=>`Title: ${catalog.titles.find(t=>t.id===id)?.name??id}`).join(', ')}`),modifiersView(i.modifiers),node('p',`${i.craftRolls??0} crafted stat rolls`),readableDefinition(i.craftPool??[]));if(i.furniture)d.append(node('p',`House furniture · ${i.furniture.width} × ${i.furniture.depth}m · ${i.furniture.container?'Storage container':'Decoration'}`));list.append(d);}
|
||||
}else if(section==='requirements'){
|
||||
list.append(button('Create requirement set',()=>setForm('requirements')),node('p','Named thresholds reusable in titles and equipment. Equipment supports level/stat thresholds; other metrics are title-only.','muted'));
|
||||
for(const s of catalog.requirementSets??[]){const d=node('details','','catalog-definition');d.append(node('summary',s.name),node('p',`${s.id} · ${s.description}`),node('p',s.requirements.map(r=>`${statLabel(r.metric)} ≥ ${r.atLeast}`).join(' / ')));list.append(d);}
|
||||
@@ -181,7 +181,7 @@ function readableDefinition(value:unknown, context=''):HTMLElement {
|
||||
const fields=node('dl','','catalog-facts');
|
||||
const record=value as Record<string,unknown>;
|
||||
for(const [key,raw] of Object.entries(record)) {
|
||||
if(['id','name','description'].includes(key))continue;
|
||||
if(['id','name','description','baseXp','xpPerLevel'].includes(key))continue;
|
||||
let item=raw;
|
||||
if(key==='resources'&&item==null&&typeof record.id==='string')item=(catalog.gathering?.resources??[]).filter(r=>r.biomes.includes(record.id as string)).map(r=>r.id);
|
||||
if(key==='biomes'&&'skillId' in record&&record.id) item=(catalog.gathering?.biomes??[]).filter(b=>b.resources!=null?b.resources.includes(record.id as string):(raw as string[]).includes(b.id)).map(b=>b.id);
|
||||
@@ -198,7 +198,7 @@ function gatheringForm(kind:string,existing?:NonNullable<Catalog['gathering']>['
|
||||
if(kind==='gathering'){
|
||||
const base=number(20,1,1000000,'1'),step=number(10,0,1000000,'1'),max=number(1000,2,10000,'1');
|
||||
const fields=form('Create gathering skill','create-gathering-skill',()=>({gatheringSkill:{...values.read(),baseXp:Number(base.value),xpPerLevel:Number(step.value),maxLevel:Number(max.value)}}));
|
||||
fields.append(values.node,field('XP from level 1 to 2',base),field('Extra XP cost per level',step),field('Maximum earned level',max),node('p','Earned XP belongs to the character. Temporary level bonuses affect gathering difficulty without granting XP or permanent levels.','muted'));
|
||||
fields.append(values.node,node('p','XP to reach level L: 100 + 10 × (L - 2)².'),field('Maximum earned level',max),node('p','Earned XP belongs to the character. Temporary level bonuses affect gathering difficulty without granting XP or permanent levels.','muted'));
|
||||
}else if(kind==='resources'){
|
||||
const skill=contentChoice(g?.skills??[]),model=select(['tree','ore','herb']),output=select(['wood','ore','herb','self']),level=number(1,1,10000,'1'),amount=number(1,1,1000,'1'),xp=number(2,0,1000000,'1'),seconds=number(1,0.1,3600),respawn=number(120,1,604800),density=number(4,0,32,'1');
|
||||
output.options[3].text='New material named after this resource';
|
||||
@@ -263,7 +263,7 @@ function combatList(){
|
||||
function powerList(){
|
||||
const p=catalog.powers;if(!p)return;
|
||||
if(section==='weapons'){
|
||||
list.append(button('Create weapon type',()=>{if(editing||saving)return;const values=identity(),base=number(100,1,1000000,'1'),per=number(50,1,1000000,'1'),max=number(1000,1,1000,'1');form('Create weapon type','create-weapon',()=>({weapon:{...values.read(),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:Number(max.value)}})).append(values.node,field('XP to level 2',base),field('Additional XP per level',per),field('Maximum level',max));}));
|
||||
list.append(button('Create weapon type',()=>{if(editing||saving)return;const values=identity(),base=number(100,1,1000000,'1'),per=number(50,1,1000000,'1'),max=number(1000,1,1000,'1');form('Create weapon type','create-weapon',()=>({weapon:{...values.read(),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:Number(max.value)}})).append(values.node,node('p','XP to reach level L: 100 + 10 × (L - 2)².'),field('Maximum level',max));}));
|
||||
for(const w of p.weapons){const d=node('details','','catalog-definition');d.append(node('summary',w.name),readableDefinition(w));list.append(d)}return;
|
||||
}
|
||||
list.append(button('Create spell or ability',powerForm));
|
||||
@@ -277,8 +277,8 @@ function powerForm(){
|
||||
const stats=repeat<{stat:string;minimum:number}>('Required stats without equipment','Add requirement',v=>{const group=node('div','','catalog-fields'),stat=select(statKeys,v?.stat),minimum=number(v?.minimum??1,0,1000000);group.append(field('Stat',stat),field('Minimum',minimum));return {node:group,read:()=>({stat:stat.value,minimum:Number(minimum.value)})}},[],32);
|
||||
const parents=repeat<{id:string;rank:number}>('Predecessor spells (all required)','Add predecessor',v=>{const group=node('div','','catalog-fields'),id=contentChoice((catalog.powers?.powers??[]).filter(p=>p.kind==='spell'),v?.id),rank=number(v?.rank??2,1,1000,'1');group.append(field('Spell',id),field('Required rank',rank));return {node:group,read:()=>({id:id.value,rank:Number(rank.value)})}},[],16);
|
||||
const titles=node('fieldset','','catalog-title-choices');titles.append(node('legend','Required titles'));const checks=catalog.titles.map(t=>{const input=node('input');input.type='checkbox';titles.append(field(t.name,input));return {id:t.id,input}});
|
||||
const fields=form('Create spell or ability','create-power',()=>{const r=stats.read(),pre=parents.read();if(new Set(r.map(v=>v.stat)).size!==r.length||new Set(pre.map(v=>v.id)).size!==pre.length)throw new Error('Requirements must not repeat.');return {power:{...values.read(),kind:kind.value,attackId:resurrection.checked?'':attack.value,targeting:resurrection.checked?'target':targeting.value,resurrection:resurrection.checked,weapon:kind.value==='ability'?weapon.value:'',weaponLevel:Number(weaponLevel.value),requirements:{level:Number(level.value),stats:Object.fromEntries(r.map(v=>[v.stat,v.minimum])),titles:checks.filter(v=>v.input.checked).map(v=>v.id)},parents:kind.value==='ability'?{}:Object.fromEntries(pre.map(v=>[v.id,v.rank])),book:kind.value==='spell'&&book.checked,mana:Number(mana.value),castSeconds:resurrection.checked?0:Number(cast.value),cooldown:Number(cooldown.value),basePower:Number(basePower.value),rankScaling:Number(scaling.value),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:kind.value==='ability'?1:Number(max.value)}}});
|
||||
fields.append(values.node,field('Kind',kind),field('Combat effect profile',attack),field('Targeting',targeting),field('Corpse resurrection (instant, adjacent, consent required)',resurrection),field('Learn from a consumable spell book',book),field('Weapon type for ability',weapon),field('Weapon level required',weaponLevel),field('Character level required',level),stats.node,titles,parents.node,field('Base effect power',basePower),field('Mana cost',mana),field('Cast time (seconds)',cast),field('Cooldown (seconds)',cooldown),field('Power increase per rank (0.03 = 3%)',scaling),field('XP to rank 2',base),field('Additional XP per rank',per),field('Maximum spell rank',max),node('p','A spell without a book automatically unlocks from its predecessor requirements. Abilities require the matching equipped weapon. Existing learned powers retain their definition. Aura profiles require a melee delivery, radius, and duration.','muted'));
|
||||
const fields=form('Create spell or ability','create-power',()=>{const r=stats.read(),pre=parents.read();if(new Set(r.map(v=>v.stat)).size!==r.length||new Set(pre.map(v=>v.id)).size!==pre.length)throw new Error('Requirements must not repeat.');return {power:{...values.read(),kind:kind.value,attackId:resurrection.checked?'':attack.value,targeting:resurrection.checked?'target':targeting.value,resurrection:resurrection.checked,weapon:kind.value==='ability'?weapon.value:'',weaponLevel:Number(weaponLevel.value),requirements:{level:Number(level.value),stats:Object.fromEntries(r.map(v=>[v.stat,v.minimum])),titles:checks.filter(v=>v.input.checked).map(v=>v.id)},parents:kind.value==='ability'?{}:Object.fromEntries(pre.map(v=>[v.id,v.rank])),book:kind.value==='spell'&&book.checked,mana:Number(mana.value),castSeconds:resurrection.checked?0:Number(cast.value),cooldown:Number(cooldown.value),basePower:Number(basePower.value),rankScaling:Number(scaling.value),baseXp:Number(base.value),xpPerLevel:Number(per.value),maxLevel:Number(max.value)}}});
|
||||
fields.append(values.node,field('Kind',kind),field('Combat effect profile',attack),field('Targeting',targeting),field('Corpse resurrection (instant, adjacent, consent required)',resurrection),field('Learn from a consumable spell book',book),field('Weapon type for ability',weapon),field('Weapon level required',weaponLevel),field('Character level required',level),stats.node,titles,parents.node,field('Base effect power',basePower),field('Mana cost',mana),field('Cast time (seconds)',cast),field('Cooldown (seconds)',cooldown),field('Power increase per rank (0.03 = 3%)',scaling),node('p','XP to reach rank L: 100 + 10 × (L - 2)².'),field('Maximum rank',max),node('p','A spell without a book automatically unlocks from its predecessor requirements. Abilities require the matching equipped weapon. Existing learned powers retain their definition. Aura profiles require a melee delivery, radius, and duration.','muted'));
|
||||
}
|
||||
|
||||
function buildingList(){
|
||||
|
||||
@@ -13,7 +13,7 @@ export function createPowerPanel(send:(op:string,target?:string,x?:number,z?:num
|
||||
casting.textContent=`Mana ${Math.floor(c.mana??0)} / ${Math.floor(c.stats?.manaPoints?.final??0)} · Stamina ${Math.floor(c.stamina??0)}${c.casting?' · '+c.casting:''}`;refreshSlots();const sig=JSON.stringify([c.powers,c.weapons,c.inventory]);if(sig===signature)return;signature=sig;known.replaceChildren();bookList.replaceChildren();
|
||||
for(const [id,n] of Object.entries(c.inventory)){if(n<1)continue;if(id.startsWith('book_')){const b=node('button',`Learn from ${c.stackNames?.[id]??statLabel(id)} (${n})`);b.type='button';b.onclick=()=>send('learn',id);bookList.append(b)}if(id==='revival_stone'){const b=node('button',`Use revival stone (${n})`);b.type='button';b.onclick=()=>void use('item');bookList.append(b)}}
|
||||
for(const v of Object.values(c.weapons??{}))known.append(node('p',`${v.name} · Level ${v.level} · ${v.xp} XP · ${v.xpToNextLevel} to next`));
|
||||
for(const v of Object.values(c.powers??{})){const d=v.definition,detail=node('details'),assign=node('select'),activate=node('button','Use '+d.name);assign.setAttribute('aria-label','Action slot for '+d.name);assign.append(new Option('Not assigned',''));for(let i=0;i<8;i++)assign.append(new Option('Slot '+(i+1),String(i)));const at=slots.indexOf(d.id);assign.value=at<0?'':String(at);assign.onchange=()=>{slots=slots.map(id=>id===d.id?'':id);if(assign.value!=='')slots[Number(assign.value)]=d.id;save()};activate.type='button';activate.onclick=()=>void use(d.id);detail.append(node('summary',`${d.name} · ${d.kind==='spell'?'Rank '+v.level:'Ability'}`),node('p',`${v.xp} XP · ${v.xpToNextLevel} to next · ${d.mana} mana · ${d.castSeconds}s cast · ${d.cooldown}s cooldown`),node('p',`${d.targeting}${d.resurrection?' · corpse revival':` · ${v.attack.effect} · ${v.attack.range}m range`}`),assign,activate);known.append(detail)}
|
||||
for(const v of Object.values(c.powers??{})){const d=v.definition,detail=node('details'),assign=node('select'),activate=node('button','Use '+d.name);assign.setAttribute('aria-label','Action slot for '+d.name);assign.append(new Option('Not assigned',''));for(let i=0;i<8;i++)assign.append(new Option('Slot '+(i+1),String(i)));const at=slots.indexOf(d.id);assign.value=at<0?'':String(at);assign.onchange=()=>{slots=slots.map(id=>id===d.id?'':id);if(assign.value!=='')slots[Number(assign.value)]=d.id;save()};activate.type='button';activate.onclick=()=>void use(d.id);detail.append(node('summary',`${d.name} · ${'Rank '+v.level}`),node('p',`${v.xp} XP · ${v.xpToNextLevel} to next · ${d.mana} mana · ${d.castSeconds}s cast · ${d.cooldown}s cooldown`),node('p',`${d.targeting}${d.resurrection?' · corpse revival':` · ${v.attack.effect} · ${v.attack.range}m range`}`),assign,activate);known.append(detail)}
|
||||
if(!Object.keys(c.powers??{}).length)known.append(node('p','Use a spell book or train a weapon to unlock powers.'));
|
||||
}
|
||||
return {root,hotbar,update,useSlot:(i:number)=>void use(slots[i])};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Shared progression curve
|
||||
|
||||
All player levels, gathering/crafting professions, weapon proficiency, learned
|
||||
spells, and abilities use `XP_next = 100 + 10(L - 2)^2`, where **L is the target
|
||||
level**. The cost is per level, not cumulative: reaching levels 2, 3, 4, and 5
|
||||
costs 100, 110, 140, and 190 XP respectively (540 XP total from level 1 to 5).
|
||||
The authoritative constants live in `server/content/balance.yaml` under `xpCurve`.
|
||||
|
||||
Abilities now gain their own XP once per useful attack, using the existing power
|
||||
XP award of 10. Misses and ineffective healing do not award XP; area ticks do not
|
||||
multiply awards. Hub/housing and dead characters earn none. Existing single-rank
|
||||
abilities become rankable up to the provisional 1,000-rank cap. Their copied
|
||||
per-rank effect scaling now applies as they level. Weapon XP remains separate.
|
||||
|
||||
On first restore/import, the versioned migration preserves earned levels and
|
||||
fractional progress, rounded down to whole XP. For example, level 3 with 100/200
|
||||
old player XP becomes level 3 with 70/140 XP. Total profession/spell/weapon XP is
|
||||
rebased to represent the same rank and progress under the new costs. It grants no
|
||||
stat points, health/mana choices, or other level-up rewards. Repeated restoration,
|
||||
resurrection, and travel do not repeat the migration; replacement starts fresh.
|
||||
The skill XP storage bound supports the existing 10,000-level gathering cap.
|
||||
|
||||
Old `baseXp` and `xpPerLevel` fields remain readable for migration and wire
|
||||
compatibility; they no longer tune individual tracks. Control shows the universal
|
||||
formula instead of misleading per-track XP inputs. Existing maximum levels and
|
||||
XP rewards remain, except the former single-rank ability limitation above.
|
||||
Legacy aggregate action counters are still counters, not separate ranked skills.
|
||||
|
||||
Upgrade all world owners together before resuming cross-world travel. Older
|
||||
binaries do not understand the migration version and shared curve. Required local
|
||||
checks include curve boundaries, multi-level awards, migration idempotence,
|
||||
high-rank bounds, ability usage, death/travel, and zero XP in hubs/housing.
|
||||
@@ -1,4 +1,5 @@
|
||||
version: 1
|
||||
xpCurve: { base: 100, quadratic: 10 }
|
||||
combatRules:
|
||||
maxMobs: 512
|
||||
maxProjectiles: 256
|
||||
@@ -248,7 +249,7 @@ crafting:
|
||||
- {"id": "recipe_component", "revision": 1, "name": "Building component", "description": "Starter building component recipe.", "profession": "builder", "level": 1, "xp": 20, "inputs": {"wood": 4, "ore": 1}, "outputs": {"building_component": 1}, "stats": {}, "titles": []}
|
||||
|
||||
# Milestone 7 provisional progression and resurrection tuning.
|
||||
powers: {"weapons": [{"id": "blades", "name": "Blades", "description": "Blades proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}, {"id": "polearms", "name": "Polearms", "description": "Polearms proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}], "powers": [{"id": "arc_bolt", "name": "Arc bolt", "description": "Arc bolt", "kind": "spell", "attackId": "arc_bolt", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0.5, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "mend", "name": "Mend", "description": "Mend", "kind": "spell", "attackId": "mend", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "renewal", "name": "Renewal aura", "description": "Renewal aura", "kind": "spell", "attackId": "renewal_aura", "targeting": "aura", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {"mend": 2}, "book": false, "mana": 10, "castSeconds": 0, "cooldown": 10, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "revive", "name": "Resurrection", "description": "Resurrection", "kind": "spell", "attackId": "", "targeting": "target", "resurrection": true, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 20, "castSeconds": 0, "cooldown": 30, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}, {"id": "cleave", "name": "Cleave", "description": "Cleave", "kind": "ability", "attackId": "cleave", "targeting": "target", "resurrection": false, "weapon": "blades", "weaponLevel": 2, "requirements": {"level": 1, "stats": {"strength": 2}, "titles": []}, "parents": {}, "book": false, "mana": 0, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1, "basePower": 0}], "weaponXp": 10, "spellXp": 10, "revivalRange": 3, "revivalHealth": 0.25}
|
||||
powers: {"weapons": [{"id": "blades", "name": "Blades", "description": "Blades proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}, {"id": "polearms", "name": "Polearms", "description": "Polearms proficiency", "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000}], "powers": [{"id": "arc_bolt", "name": "Arc bolt", "description": "Arc bolt", "kind": "spell", "attackId": "arc_bolt", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0.5, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "mend", "name": "Mend", "description": "Mend", "kind": "spell", "attackId": "mend", "targeting": "target", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 5, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "renewal", "name": "Renewal aura", "description": "Renewal aura", "kind": "spell", "attackId": "renewal_aura", "targeting": "aura", "resurrection": false, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {"mend": 2}, "book": false, "mana": 10, "castSeconds": 0, "cooldown": 10, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 10}, {"id": "revive", "name": "Resurrection", "description": "Resurrection", "kind": "spell", "attackId": "", "targeting": "target", "resurrection": true, "weapon": "", "weaponLevel": 1, "requirements": {"level": 1, "stats": {}, "titles": []}, "parents": {}, "book": true, "mana": 20, "castSeconds": 0, "cooldown": 30, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}, {"id": "cleave", "name": "Cleave", "description": "Cleave", "kind": "ability", "attackId": "cleave", "targeting": "target", "resurrection": false, "weapon": "blades", "weaponLevel": 2, "requirements": {"level": 1, "stats": {"strength": 2}, "titles": []}, "parents": {}, "book": false, "mana": 0, "castSeconds": 0, "cooldown": 2, "rankScaling": 0.03, "baseXp": 100, "xpPerLevel": 50, "maxLevel": 1000, "basePower": 0}], "weaponXp": 10, "spellXp": 10, "revivalRange": 3, "revivalHealth": 0.25}
|
||||
|
||||
# Milestone 8a provisional structure limits and blueprints. Recipes are authored in Control.
|
||||
building:
|
||||
|
||||
@@ -19,6 +19,7 @@ type Recipe struct {
|
||||
}
|
||||
|
||||
type Balance struct {
|
||||
XPCurve *XPCurve `yaml:"xpCurve"`
|
||||
Housing *HousingRules `yaml:"housing"`
|
||||
Building *BuildingContent `yaml:"building"`
|
||||
Powers *PowerContent `yaml:"powers"`
|
||||
@@ -84,6 +85,11 @@ func Parse(data []byte) (Balance, error) {
|
||||
return b, b.Validate()
|
||||
}
|
||||
func (b Balance) Validate() error {
|
||||
if b.XPCurve != nil {
|
||||
if e := b.XPCurve.Validate(); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
if b.Housing != nil {
|
||||
if e := b.Housing.Validate(); e != nil {
|
||||
return e
|
||||
|
||||
@@ -72,7 +72,7 @@ func (r CraftRules) Loss(level int64) float64 {
|
||||
func SkillLevel(s GatheringSkill, xp int64) (int64, int64) {
|
||||
level := int64(1)
|
||||
for level < s.MaxLevel {
|
||||
need := s.BaseXP + (level-1)*s.XPPerLevel
|
||||
need := XPForLevel(level + 1)
|
||||
if xp < need {
|
||||
return level, need - xp
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go.yaml.in/yaml/v3"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type XPCurve struct {
|
||||
Base int64 `yaml:"base"`
|
||||
Quadratic int64 `yaml:"quadratic"`
|
||||
}
|
||||
|
||||
func (x XPCurve) Validate() error {
|
||||
if x.Base != 100 || x.Quadratic != 10 {
|
||||
return fmt.Errorf("XP curve must be 100 + 10(L-2)^2")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// This global gameplay rule applies to existing worlds and copied definitions too.
|
||||
// Read its tuning once from the embedded balance instead of a character's legacy curve.
|
||||
var currentXPCurve = sync.OnceValue(func() XPCurve {
|
||||
var b struct {
|
||||
XP XPCurve `yaml:"xpCurve"`
|
||||
}
|
||||
if e := yaml.Unmarshal(balance, &b); e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if e := b.XP.Validate(); e != nil {
|
||||
panic(e)
|
||||
}
|
||||
return b.XP
|
||||
})
|
||||
|
||||
func XPForLevel(target int64) int64 {
|
||||
x := currentXPCurve()
|
||||
n := max(int64(0), min(target, int64(10000))-2)
|
||||
return x.Base + x.Quadratic*n*n
|
||||
}
|
||||
|
||||
func RebaseLevelXP(xp, oldCost, newCost int64) int64 {
|
||||
return min(newCost-1, int64(float64(xp)/float64(oldCost)*float64(newCost)))
|
||||
}
|
||||
|
||||
// Rebase legacy total XP without taking away levels or granting migration rewards.
|
||||
func RebaseSkillXP(s GatheringSkill, xp int64) int64 {
|
||||
level := int64(1)
|
||||
for level < s.MaxLevel {
|
||||
cost := s.BaseXP + (level-1)*s.XPPerLevel
|
||||
if xp < cost {
|
||||
break
|
||||
}
|
||||
xp -= cost
|
||||
level++
|
||||
}
|
||||
total := int64(0)
|
||||
for l := int64(2); l <= level; l++ {
|
||||
total += XPForLevel(l)
|
||||
}
|
||||
if level < s.MaxLevel {
|
||||
total += RebaseLevelXP(xp, s.BaseXP+(level-1)*s.XPPerLevel, XPForLevel(level+1))
|
||||
}
|
||||
return total
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (w *World) restoreCrafting(c *Character) error {
|
||||
return errors.New("invalid crafting history")
|
||||
}
|
||||
for _, v := range c.View.Crafting {
|
||||
if v.XP < 0 || v.XP > 1000000000000 {
|
||||
if v.XP < 0 || v.XP > 10000000000000 {
|
||||
return errors.New("invalid crafting experience")
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (w *World) AttemptCraft(c *Character, req p.CraftRequest) (p.CraftResult, e
|
||||
}
|
||||
}
|
||||
if w.AllowsXP() {
|
||||
progress.XP = min(int64(1000000000000), progress.XP+recipe.XP)
|
||||
progress.XP = min(int64(10000000000000), progress.XP+recipe.XP)
|
||||
c.View.Crafting[req.Profession] = progress
|
||||
c.View.Skills["crafting"] += w.Balance.SkillXpPerAction
|
||||
w.grantXP(c, w.Balance.Progression.CraftXP)
|
||||
|
||||
@@ -24,7 +24,7 @@ func stringValue(s *string) string {
|
||||
|
||||
func (w *World) restoreGathering(c *Character) error {
|
||||
for _, xp := range c.View.Skills {
|
||||
if xp < 0 || xp > 1000000000000 {
|
||||
if xp < 0 || xp > 10000000000000 {
|
||||
return errors.New("invalid persisted skill XP")
|
||||
}
|
||||
}
|
||||
@@ -107,20 +107,7 @@ func (w *World) refreshGathering(c *Character) {
|
||||
}
|
||||
for _, s := range w.Balance.Gathering.Skills {
|
||||
xp := max(0, c.View.Skills[s.ID])
|
||||
remaining := xp
|
||||
level := int64(1)
|
||||
for level < s.MaxLevel {
|
||||
cost := s.BaseXP + (level-1)*s.XPPerLevel
|
||||
if remaining < cost {
|
||||
break
|
||||
}
|
||||
remaining -= cost
|
||||
level++
|
||||
}
|
||||
next := s.BaseXP + (level-1)*s.XPPerLevel - remaining
|
||||
if level == s.MaxLevel {
|
||||
next = 0
|
||||
}
|
||||
level, next := content.SkillLevel(s, xp)
|
||||
lv := value(s.ID, "gatheringLevel", float64(level), 1, 10000)
|
||||
c.View.Gathering[s.ID] = p.SkillProgress{Name: s.Name, XP: xp, Level: level, XPToNextLevel: next, EffectiveLevel: int64(math.Floor(lv.Final)), LevelValue: lv, Yield: value(s.ID, "gatheringYield", c.View.Stats["gatherRate"].Final, 0, 100000), Speed: value(s.ID, "gatheringSpeed", 100, 10, 1000), Experience: value(s.ID, "gatheringXP", c.View.Stats["xpGain"].Final, 0, 100000)}
|
||||
}
|
||||
@@ -231,9 +218,9 @@ func (w *World) gather(c *Character, target string) error {
|
||||
}
|
||||
}
|
||||
xp := int64(math.Min(1000000000, float64(r.XP)*c.View.Gathering[r.SkillID].Experience.Final/100))
|
||||
c.View.Skills[r.SkillID] = min(int64(1000000000000), c.View.Skills[r.SkillID]+xp)
|
||||
c.View.Skills[r.SkillID] = min(int64(10000000000000), c.View.Skills[r.SkillID]+xp)
|
||||
// Keep the legacy aggregate for existing title predicates, never as a level.
|
||||
c.View.Skills["gathering"] = min(int64(1000000000000), c.View.Skills["gathering"]+w.Balance.SkillXpPerAction)
|
||||
c.View.Skills["gathering"] = min(int64(10000000000000), c.View.Skills["gathering"]+w.Balance.SkillXpPerAction)
|
||||
w.Depleted[target] = w.Age() + r.RespawnSeconds
|
||||
label := output
|
||||
if r.Output == "self" {
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestGatheringProgressAndEffectsTravel(t *testing.T) {
|
||||
if err := dest.Import(c); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.View.Skills["miner"] != 90 || c.View.Gathering["miner"].Level != 4 || c.View.Gathering["miner"].EffectiveLevel != 9 || c.DailySeconds != 123 || c.View.GatheringEffects[0].ExpiresAt != expiry {
|
||||
if c.View.Skills["miner"] != 90 || c.View.Gathering["miner"].Level != 1 || c.View.Gathering["miner"].EffectiveLevel != 6 || c.DailySeconds != 123 || c.View.GatheringEffects[0].ExpiresAt != expiry {
|
||||
t.Fatal("travel reset XP, usage, or renewed effects")
|
||||
}
|
||||
if err := dest.Connect(c.View.Entity.ID); err != nil {
|
||||
|
||||
@@ -59,7 +59,7 @@ func (w *World) restorePowers(c *Character) error {
|
||||
return errors.New("invalid learned power history")
|
||||
}
|
||||
for id, v := range c.View.Powers {
|
||||
if id != v.Definition.ID || v.XP < 0 || v.XP > 1000000000000 || !finiteCraft(v.ReadyAt) || v.Definition.BaseXP < 1 || v.Definition.XPPerLevel < 1 || v.Definition.MaxLevel < 1 || v.Definition.MaxLevel > 1000 {
|
||||
if id != v.Definition.ID || v.XP < 0 || v.XP > 10000000000000 || !finiteCraft(v.ReadyAt) || v.Definition.BaseXP < 1 || v.Definition.XPPerLevel < 1 || v.Definition.MaxLevel < 1 || v.Definition.MaxLevel > 1000 {
|
||||
return errors.New("invalid learned spell")
|
||||
}
|
||||
d := v.Definition
|
||||
@@ -76,7 +76,7 @@ func (w *World) restorePowers(c *Character) error {
|
||||
}
|
||||
}
|
||||
for _, v := range c.View.Weapons {
|
||||
if v.XP < 0 || v.XP > 1000000000000 {
|
||||
if v.XP < 0 || v.XP > 10000000000000 {
|
||||
return errors.New("invalid weapon XP")
|
||||
}
|
||||
}
|
||||
@@ -116,10 +116,13 @@ func (w *World) powerRequirements(c *Character, d p.PowerDefinition) bool {
|
||||
return true
|
||||
}
|
||||
func (w *World) acquirePower(c *Character, d content.PowerDefinition) {
|
||||
if d.Kind == "ability" && d.MaxLevel == 1 {
|
||||
d.MaxLevel = 1000
|
||||
}
|
||||
var definition p.PowerDefinition
|
||||
raw, _ := json.Marshal(d)
|
||||
_ = json.Unmarshal(raw, &definition)
|
||||
v := p.LearnedPower{Definition: definition, Level: 1, XPToNextLevel: d.BaseXP}
|
||||
v := p.LearnedPower{Definition: definition, Level: 1, XPToNextLevel: content.XPForLevel(2)}
|
||||
for _, a := range w.Balance.Combat.Attacks {
|
||||
if a.ID == d.AttackID {
|
||||
v.Attack = protocolAttack(a)
|
||||
@@ -215,15 +218,15 @@ func (w *World) awardCombatCredit(shot Projectile) {
|
||||
credit.Rewarded = true
|
||||
if credit.Power != "" {
|
||||
v, ok := c.View.Powers[credit.Power]
|
||||
if ok && v.Definition.Kind == "spell" {
|
||||
v.XP = min(int64(1000000000000), v.XP+w.Balance.Powers.SpellXP)
|
||||
if ok {
|
||||
v.XP = min(int64(10000000000000), v.XP+w.Balance.Powers.SpellXP)
|
||||
c.View.Powers[credit.Power] = v
|
||||
}
|
||||
}
|
||||
if credit.Weapon != "" {
|
||||
v, ok := c.View.Weapons[credit.Weapon]
|
||||
if ok {
|
||||
v.XP = min(int64(1000000000000), v.XP+w.Balance.Powers.WeaponXP)
|
||||
v.XP = min(int64(10000000000000), v.XP+w.Balance.Powers.WeaponXP)
|
||||
c.View.Weapons[credit.Weapon] = v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"aeternalis/server/content"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
)
|
||||
|
||||
@@ -66,6 +67,9 @@ func (w *World) restoreProgression(c *Character) error {
|
||||
if c.View.Level < 1 || c.View.Level > c.Progression.MaxLevel || c.View.Experience < 0 || c.View.StatPoints < 0 {
|
||||
return errors.New("invalid persisted character progression")
|
||||
}
|
||||
if e := w.migrateXPCurve(c); e != nil {
|
||||
return e
|
||||
}
|
||||
c.View.ExperienceToNextLevel = c.nextLevelXP()
|
||||
if (c.View.ExperienceToNextLevel == 0 && c.View.Experience != 0) || (c.View.ExperienceToNextLevel > 0 && c.View.Experience >= c.View.ExperienceToNextLevel) {
|
||||
return errors.New("invalid persisted level XP")
|
||||
@@ -85,7 +89,7 @@ func (c *Character) nextLevelXP() int64 {
|
||||
if c.View.Level >= c.Progression.MaxLevel {
|
||||
return 0
|
||||
}
|
||||
return c.Progression.BaseXP + (c.View.Level-1)*c.Progression.XPPerLevel
|
||||
return content.XPForLevel(c.View.Level + 1)
|
||||
}
|
||||
|
||||
func (w *World) grantXP(c *Character, amount int64) {
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestLevelUpsBankPointsAndCap(t *testing.T) {
|
||||
t.Fatal("premature level")
|
||||
}
|
||||
w.grantXP(c, 151)
|
||||
if c.View.Level != 3 || c.View.Experience != 0 || c.View.StatPoints != 20 || c.View.ExperienceToNextLevel != 200 {
|
||||
if c.View.Level != 3 || c.View.Experience != 40 || c.View.StatPoints != 20 || c.View.ExperienceToNextLevel != 140 {
|
||||
t.Fatalf("multi-level award lost points or XP: %+v", c.View)
|
||||
}
|
||||
c.Progression.MaxLevel = 4
|
||||
@@ -110,7 +110,7 @@ func TestProgressionSurvivesRestartDeathAndTransfer(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded := restored.Characters[c.View.Entity.ID]
|
||||
if loaded.View.Level != 3 || loaded.View.Experience != 25 || loaded.View.StatPoints != 20 || !reflect.DeepEqual(loaded.View.Titles, c.View.Titles) {
|
||||
if loaded.View.Level != 3 || loaded.View.Experience != 65 || loaded.View.StatPoints != 20 || !reflect.DeepEqual(loaded.View.Titles, c.View.Titles) {
|
||||
t.Fatal("restart reset progression")
|
||||
}
|
||||
loaded.View.Entity.State = "eligible"
|
||||
@@ -123,12 +123,12 @@ func TestProgressionSurvivesRestartDeathAndTransfer(t *testing.T) {
|
||||
if err = destination.Import(loaded); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.View.ExperienceToNextLevel != 200 || loaded.Progression.StatPointsPerLevel != 10 || loaded.DailySeconds != 123 || loaded.WorldKills != 0 || loaded.View.StatPoints != 20 || len(loaded.View.Titles) != 1 {
|
||||
if loaded.View.ExperienceToNextLevel != 140 || loaded.Progression.StatPointsPerLevel != 10 || loaded.DailySeconds != 123 || loaded.WorldKills != 0 || loaded.View.StatPoints != 20 || len(loaded.View.Titles) != 1 {
|
||||
t.Fatal("transfer altered progression, titles, or daily budget")
|
||||
}
|
||||
destination.kill(loaded, "test death")
|
||||
destination.grantXP(loaded, 1000)
|
||||
if loaded.View.StatPoints != 20 || loaded.View.Experience != 25 || len(loaded.View.Titles) != 1 {
|
||||
if loaded.View.StatPoints != 20 || loaded.View.Experience != 65 || len(loaded.View.Titles) != 1 {
|
||||
t.Fatal("death erased progression or allowed postmortem XP")
|
||||
}
|
||||
replacement, err := destination.Join(loaded.Account, "Replacement")
|
||||
@@ -252,7 +252,7 @@ func TestBossXPAndSurvivalMilestoneGrantedOnce(t *testing.T) {
|
||||
if err := w.Intent(c.View.Entity.ID, p.Intent{Op: "attack", Seq: 1, Target: "boss"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.BossKills != 1 || c.WorldsSurvived != 1 || offline.WorldsSurvived != 1 || dead.WorldsSurvived != 0 || c.View.Level != 4 || c.View.Experience != 50 || c.View.StatPoints != 30 {
|
||||
if c.BossKills != 1 || c.WorldsSurvived != 1 || offline.WorldsSurvived != 1 || dead.WorldsSurvived != 0 || c.View.Level != 4 || c.View.Experience != 150 || c.View.StatPoints != 30 {
|
||||
t.Fatal("incorrect boss progression")
|
||||
}
|
||||
if w.Intent(c.View.Entity.ID, p.Intent{Op: "attack", Seq: 2, Target: "boss"}) == nil {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type Character struct {
|
||||
XPCurveVersion int `json:"xpCurveVersion"`
|
||||
PendingCast *PendingCast `json:"pendingCast,omitempty"`
|
||||
RevivalCorpse string `json:"revivalCorpse,omitempty"`
|
||||
RevivalAllowed bool `json:"revivalAllowed"`
|
||||
@@ -358,7 +359,7 @@ func (w *World) Join(account, name string) (*Character, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &Character{Account: account, Day: w.now.UTC().Format(time.DateOnly), View: p.Character{Entity: p.Entity{ID: ID(), Kind: "player", Name: name, Position: pos, HP: w.Balance.PlayerHp, MaxHP: w.Balance.PlayerHp, State: "alive"}, Inventory: map[string]int64{}, Skills: map[string]int64{}, RemainingSeconds: w.Balance.DailyPlaySeconds}}
|
||||
c := &Character{XPCurveVersion: 1, Account: account, Day: w.now.UTC().Format(time.DateOnly), View: p.Character{Entity: p.Entity{ID: ID(), Kind: "player", Name: name, Position: pos, HP: w.Balance.PlayerHp, MaxHP: w.Balance.PlayerHp, State: "alive"}, Inventory: map[string]int64{}, Skills: map[string]int64{}, RemainingSeconds: w.Balance.DailyPlaySeconds}}
|
||||
if err := w.restoreProgression(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func (w *World) migrateXPCurve(c *Character) error {
|
||||
if c.XPCurveVersion == 1 {
|
||||
return nil
|
||||
}
|
||||
if c.XPCurveVersion != 0 {
|
||||
return errors.New("unsupported XP curve version")
|
||||
}
|
||||
if c.View.Level < c.Progression.MaxLevel {
|
||||
old := c.Progression.BaseXP + (c.View.Level-1)*c.Progression.XPPerLevel
|
||||
if c.View.Experience >= old {
|
||||
return errors.New("invalid legacy level XP")
|
||||
}
|
||||
c.View.Experience = content.RebaseLevelXP(c.View.Experience, old, content.XPForLevel(c.View.Level+1))
|
||||
}
|
||||
valid := func(xp int64) bool { return xp >= 0 && xp <= 1000000000000 }
|
||||
if w.Balance.Gathering != nil {
|
||||
for _, s := range w.Balance.Gathering.Skills {
|
||||
xp := c.View.Skills[s.ID]
|
||||
if !valid(xp) {
|
||||
return errors.New("invalid legacy skill XP")
|
||||
}
|
||||
if xp > 0 {
|
||||
c.View.Skills[s.ID] = content.RebaseSkillXP(s, xp)
|
||||
}
|
||||
}
|
||||
}
|
||||
if w.Balance.Crafting != nil {
|
||||
for _, s := range w.Balance.Crafting.Professions {
|
||||
v, ok := c.View.Crafting[s.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if !valid(v.XP) {
|
||||
return errors.New("invalid legacy crafting XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(s, v.XP)
|
||||
c.View.Crafting[s.ID] = v
|
||||
}
|
||||
}
|
||||
if w.Balance.Powers != nil {
|
||||
for _, s := range w.Balance.Powers.Weapons {
|
||||
v, ok := c.View.Weapons[s.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if !valid(v.XP) {
|
||||
return errors.New("invalid legacy weapon XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(s, v.XP)
|
||||
c.View.Weapons[s.ID] = v
|
||||
}
|
||||
}
|
||||
for id, v := range c.View.Powers {
|
||||
d := v.Definition
|
||||
if !valid(v.XP) || d.BaseXP < 1 || d.XPPerLevel < 1 || d.MaxLevel < 1 || d.MaxLevel > 1000 {
|
||||
return errors.New("invalid legacy power XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(content.GatheringSkill{BaseXP: d.BaseXP, XPPerLevel: d.XPPerLevel, MaxLevel: d.MaxLevel}, v.XP)
|
||||
if d.Kind == "ability" && d.MaxLevel == 1 {
|
||||
v.Definition.MaxLevel = 1000
|
||||
}
|
||||
c.View.Powers[id] = v
|
||||
}
|
||||
c.XPCurveVersion = 1
|
||||
w.dirty = true
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUniversalXPCurveAndLegacyMigration(t *testing.T) {
|
||||
for target, want := range map[int64]int64{2: 100, 3: 110, 4: 140, 5: 190, 10: 740, 100: 96140} {
|
||||
if got := content.XPForLevel(target); got != want {
|
||||
t.Fatal(target, got, want)
|
||||
}
|
||||
}
|
||||
w, c := fixture(t)
|
||||
c.XPCurveVersion = 0
|
||||
c.View.Level = 3
|
||||
c.View.Experience = 100
|
||||
c.View.StatPoints = 20
|
||||
c.View.PendingVitalChoices = 2
|
||||
c.View.Skills["miner"] = 110
|
||||
v := c.View.Crafting["builder"]
|
||||
v.XP = 175
|
||||
c.View.Crafting["builder"] = v
|
||||
weapon := c.View.Weapons["blades"]
|
||||
weapon.XP = 175
|
||||
c.View.Weapons["blades"] = weapon
|
||||
c.View.Inventory["book_mend"] = 1
|
||||
if e := w.LearnPower(c, "book_mend"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
power := c.View.Powers["mend"]
|
||||
power.XP = 175
|
||||
c.View.Powers["mend"] = power
|
||||
if e := w.restoreProgression(c); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
w.RefreshStats(c)
|
||||
if c.View.Level != 3 || c.View.Experience != 70 || c.View.StatPoints != 20 || c.View.PendingVitalChoices != 2 {
|
||||
t.Fatal("player migration changed level/rewards or lost half-level progress")
|
||||
}
|
||||
if c.View.Gathering["miner"].Level != 4 || c.View.Gathering["miner"].XPToNextLevel != 114 {
|
||||
t.Fatal("gathering migration", c.View.Gathering["miner"])
|
||||
}
|
||||
if c.View.Crafting["builder"].Level != 2 || c.View.Crafting["builder"].XPToNextLevel != 55 || c.View.Weapons["blades"].XP != 155 || c.View.Powers["mend"].XP != 155 {
|
||||
t.Fatal("tracks disagree on the shared curve")
|
||||
}
|
||||
before, _ := json.Marshal(c.View)
|
||||
if e := w.restoreProgression(c); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
w.RefreshStats(c)
|
||||
after, _ := json.Marshal(c.View)
|
||||
if string(before) != string(after) {
|
||||
t.Fatal("migration repeated on restore")
|
||||
}
|
||||
s := content.GatheringSkill{BaseXP: 20, XPPerLevel: 10, MaxLevel: 10000}
|
||||
xp := content.RebaseSkillXP(s, 1000000000000)
|
||||
if level, _ := content.SkillLevel(s, xp); level != 10000 || xp > 10000000000000 {
|
||||
t.Fatal("maximum rank migration overflow")
|
||||
}
|
||||
}
|
||||
func TestAbilityUsageLevelsAndSuppressesHubXP(t *testing.T) {
|
||||
w, c := fixture(t)
|
||||
d := w.Balance.Powers.Powers[len(w.Balance.Powers.Powers)-1]
|
||||
if d.Kind != "ability" {
|
||||
t.Fatal("ability fixture missing")
|
||||
}
|
||||
w.acquirePower(c, d)
|
||||
for range 21 {
|
||||
w.awardCombatCredit(Projectile{Source: c.View.Entity.ID, Player: true, Credit: &CombatCredit{Power: d.ID}})
|
||||
}
|
||||
if v := c.View.Powers[d.ID]; v.Level != 3 || v.XP != 210 || v.XPToNextLevel != 140 {
|
||||
t.Fatal("ability rank curve", v)
|
||||
}
|
||||
w.Kind = "hub"
|
||||
w.Phase = "hub"
|
||||
w.awardCombatCredit(Projectile{Source: c.View.Entity.ID, Player: true, Credit: &CombatCredit{Power: d.ID}})
|
||||
if c.View.Powers[d.ID].XP != 210 {
|
||||
t.Fatal("hub ability XP")
|
||||
}
|
||||
c.View.Entity.State = "dead"
|
||||
w.Kind = "survival"
|
||||
w.Phase = "gathering"
|
||||
w.awardCombatCredit(Projectile{Source: c.View.Entity.ID, Player: true, Credit: &CombatCredit{Power: d.ID}})
|
||||
if c.View.Powers[d.ID].XP != 210 {
|
||||
t.Fatal("dead ability XP")
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,14 @@ func decodeCatalog(version int64, raw string) (content.Catalog, error) {
|
||||
}
|
||||
catalog.RestoreFurniture(b)
|
||||
}
|
||||
if catalog.Powers != nil {
|
||||
for i := range catalog.Powers.Powers {
|
||||
d := &catalog.Powers.Powers[i]
|
||||
if d.Kind == "ability" && d.MaxLevel == 1 {
|
||||
d.MaxLevel = 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
return catalog, catalog.Validate()
|
||||
}
|
||||
func (d *DB) Catalog(ctx context.Context) (content.Catalog, error) {
|
||||
|
||||
Reference in New Issue
Block a user