优化
This commit is contained in:
parent
d2e1625c43
commit
9a5eb6433f
|
|
@ -2,7 +2,9 @@
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Game\" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Game\" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@
|
||||||
<component name="PhpStanOptionsConfiguration">
|
<component name="PhpStanOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="PhpUnit">
|
||||||
|
<phpunit_settings>
|
||||||
|
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
|
||||||
|
</phpunit_settings>
|
||||||
|
</component>
|
||||||
<component name="PsalmOptionsConfiguration">
|
<component name="PsalmOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"player":{"hp":110,"maxHp":50,"patk":10,"matk":5,"pdef":5,"mdef":3,"crit":5,"critdmg":130,"level":3,"exp":160,"maxExp":225,"inventory":[{"name":"雷霆锤","type":"weapon","quality":"common","level":1,"patk":8,"matk":3,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":[],"desc":"Lv.1 common品质的武器","id":"692fa0f61aa45","quantity":1}],"equip":{"weapon":{"name":"青钢剑","type":"weapon","quality":"rare","level":1,"patk":14,"matk":3,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":["暴击伤害 +6"],"desc":"Lv.1 rare品质的武器","id":"692ee8e0df082","quantity":1},"armor":{"name":"皮甲","type":"armor","quality":"common","level":3,"patk":0,"matk":0,"pdef":6,"mdef":1,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":[],"desc":"Lv.3 common品质的防具","id":"692efecedbc7a","quantity":1}},"spiritStones":91,"npcFlags":[],"talentPoints":0,"talents":{"hp":6,"patk":0,"matk":0,"pdef":0,"mdef":0,"crit":0,"critdmg":0},"mana":100,"maxMana":100,"spells":[],"spellBooks":{"3":1,"1":2,"10":2},"partners":[{"id":"li_feiyu","name":"厉飞雨","level":2,"exp":132,"maxExp":150,"baseStats":{"hp":100,"patk":15,"matk":5,"pdef":5,"mdef":3,"crit":10,"critdmg":130,"growth":1.2},"equip":{"weapon":{"name":"青钢剑","type":"weapon","quality":"common","level":1,"patk":6,"matk":2,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":[],"desc":"Lv.1 common品质的武器","id":"692ee91453dd8","quantity":1}},"talents":{"hp":1,"patk":1,"matk":0,"pdef":0,"mdef":0,"crit":1,"critdmg":0},"talentWeights":{"hp":1,"patk":3,"matk":1,"pdef":1,"mdef":1,"crit":3,"critdmg":2},"mana":80,"maxMana":80,"spells":[],"spellBooks":[]}]},"dungeonId":1,"state":0}
|
{"player":{"hp":270,"maxHp":0,"patk":10,"matk":5,"pdef":5,"mdef":3,"crit":5,"critdmg":130,"level":11,"exp":1337,"maxExp":5743,"inventory":[{"name":"玄铁剑","type":"weapon","quality":"common","level":1,"patk":11,"matk":0,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":[],"desc":"Lv.1 common品质的武器","id":"6930554849acb","quantity":1},{"name":"金疮药","type":"consume","quality":"common","level":1,"patk":0,"matk":0,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":35,"affixes":[],"desc":"Lv.1 common品质的药剂","id":"6930578fb29f6","quantity":91},{"name":"培元丹","type":"consume","quality":"common","level":5,"patk":0,"matk":0,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":61,"affixes":[],"desc":"Lv.5 common品质的药剂","id":"693057959f5c2","quantity":1},{"name":"玄铁剑","type":"weapon","quality":"common","level":1,"patk":10,"matk":1,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":[],"desc":"Lv.1 common品质的武器","id":"69305a28d318c","quantity":1},{"name":"金疮药","type":"consume","quality":"common","level":1,"patk":0,"matk":0,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":37,"affixes":[],"desc":"Lv.1 common品质的药剂","id":"69305a3d522a2","quantity":1}],"equip":{"weapon":{"name":"烈焰刀","type":"weapon","quality":"legendary","level":1,"patk":35,"matk":50,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":27,"heal":0,"affixes":["暴击率 +7","物攻 +15","魔攻 +8%"],"desc":"Lv.1 legendary品质的武器","id":"693041a47105c","quantity":1,"enhanceLevel":0},"armor":{"name":"皮甲","type":"armor","quality":"legendary","level":3,"patk":0,"matk":0,"pdef":26,"mdef":8,"hp":92,"crit":0,"critdmg":0,"heal":0,"affixes":["物攻 +3%","魔攻 +8%","物防 +16"],"desc":"Lv.3 legendary品质的防具","id":"693044ffc1381","quantity":1,"enhanceLevel":0},"necklace":{"name":"金链","type":"necklace","quality":"rare","level":5,"patk":0,"matk":0,"pdef":0,"mdef":0,"hp":57,"crit":0,"critdmg":0,"heal":0,"affixes":["物防 +9"],"desc":"Lv.5 rare品质的项链","id":"693046bc441b6","quantity":1,"enhanceLevel":0}},"spiritStones":3286,"npcFlags":[],"talentPoints":15,"talents":{"hp":12,"patk":0,"matk":0,"pdef":0,"mdef":0,"crit":0,"critdmg":0},"mana":100,"maxMana":100,"spells":[],"spellBooks":{"3":1,"1":40,"10":36},"partners":[{"id":"li_feiyu","name":"厉飞雨","level":13,"exp":301,"maxExp":337,"equip":{"weapon":{"name":"玄铁剑","type":"weapon","quality":"rare","level":5,"patk":15,"matk":1,"pdef":0,"mdef":0,"hp":0,"crit":0,"critdmg":0,"heal":0,"affixes":["暴击 +5"],"desc":"Lv.5 common品质的武器","id":"693055329e36e","quantity":1}},"talents":{"hp":36,"patk":3,"matk":0,"pdef":0,"mdef":0,"crit":0,"critdmg":0},"talentWeights":{"hp":1,"patk":1,"matk":1,"pdef":1,"mdef":1,"crit":1,"critdmg":1},"mana":100,"maxMana":100,"spells":[],"spellBooks":[],"hp":338,"maxHp":0,"patk":15,"matk":5,"pdef":5,"mdef":3,"crit":10,"critdmg":130}]},"dungeonId":1,"state":2}
|
||||||
|
|
@ -123,7 +123,6 @@ class Game
|
||||||
'level' => $partner->level,
|
'level' => $partner->level,
|
||||||
'exp' => $partner->exp,
|
'exp' => $partner->exp,
|
||||||
'maxExp' => $partner->maxExp,
|
'maxExp' => $partner->maxExp,
|
||||||
'baseStats' => $partner->baseStats,
|
|
||||||
'equip' => $partner->equip,
|
'equip' => $partner->equip,
|
||||||
'talents' => $partner->talents,
|
'talents' => $partner->talents,
|
||||||
'talentWeights' => $partner->talentWeights,
|
'talentWeights' => $partner->talentWeights,
|
||||||
|
|
@ -131,6 +130,16 @@ class Game
|
||||||
'maxMana' => $partner->maxMana,
|
'maxMana' => $partner->maxMana,
|
||||||
'spells' => $partner->spells,
|
'spells' => $partner->spells,
|
||||||
'spellBooks' => $partner->spellBooks,
|
'spellBooks' => $partner->spellBooks,
|
||||||
|
|
||||||
|
'hp' => $partner->hp,
|
||||||
|
'maxHp' => $partner->maxHp,
|
||||||
|
'patk' => $partner->patk,
|
||||||
|
'matk' => $partner->matk,
|
||||||
|
'pdef' => $partner->pdef,
|
||||||
|
'mdef' => $partner->mdef,
|
||||||
|
'crit' => $partner->crit,
|
||||||
|
'critdmg' => $partner->critdmg,
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ return [
|
||||||
'exp' => 100,
|
'exp' => 100,
|
||||||
'spirit_stones' => 20,
|
'spirit_stones' => 20,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '眨眼剑法', 'quality' => 'rare', 'patk' => 15, 'rate' => 20, 'affixes' => ['crit' => 5]],
|
['type' => 'weapon', 'name' => '眨眼剑法', 'quality' => 'rare', 'patk' => 15, 'rate' => 20],
|
||||||
['type' => 'necklace', 'name' => '长生锁', 'rate' => 15] + $necklaceTemplate,
|
['type' => 'necklace', 'name' => '长生锁', 'rate' => 15] + $necklaceTemplate,
|
||||||
['type' => 'consume', 'name' => '清灵散', 'rate' => 40, 'heal' => 80],
|
['type' => 'consume', 'name' => '清灵散', 'rate' => 40, 'heal' => 80],
|
||||||
],
|
],
|
||||||
|
|
@ -255,7 +255,7 @@ return [
|
||||||
'exp' => 300,
|
'exp' => 300,
|
||||||
'spirit_stones' => 100,
|
'spirit_stones' => 100,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '金竺笔', 'quality' => 'epic', 'matk' => 45, 'rate' => 15, 'affixes' => ['matk' => 10]],
|
['type' => 'weapon', 'name' => '金竺笔', 'quality' => 'epic', 'matk' => 45, 'rate' => 15],
|
||||||
['type' => 'armor', 'name' => '墨蛟甲', 'quality' => 'epic', 'pdef' => 20, 'mdef' => 15, 'rate' => 15],
|
['type' => 'armor', 'name' => '墨蛟甲', 'quality' => 'epic', 'pdef' => 20, 'mdef' => 15, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '筑基丹', 'rate' => 50, 'heal' => 500],
|
['type' => 'consume', 'name' => '筑基丹', 'rate' => 50, 'heal' => 500],
|
||||||
],
|
],
|
||||||
|
|
@ -370,7 +370,7 @@ return [
|
||||||
'exp' => 600,
|
'exp' => 600,
|
||||||
'spirit_stones' => 250,
|
'spirit_stones' => 250,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '血灵钻', 'quality' => 'epic', 'matk' => 100, 'rate' => 20, 'affixes' => ['crit' => 10]],
|
['type' => 'weapon', 'name' => '血灵钻', 'quality' => 'epic', 'matk' => 100, 'rate' => 20],
|
||||||
['type' => 'armor', 'name' => '血灵甲', 'quality' => 'epic', 'pdef' => 40, 'mdef' => 30, 'rate' => 20],
|
['type' => 'armor', 'name' => '血灵甲', 'quality' => 'epic', 'pdef' => 40, 'mdef' => 30, 'rate' => 20],
|
||||||
['type' => 'consume', 'name' => '血灵丹', 'rate' => 30, 'heal' => 1000],
|
['type' => 'consume', 'name' => '血灵丹', 'rate' => 30, 'heal' => 1000],
|
||||||
],
|
],
|
||||||
|
|
@ -426,7 +426,7 @@ return [
|
||||||
'exp' => 1000,
|
'exp' => 1000,
|
||||||
'spirit_stones' => 400,
|
'spirit_stones' => 400,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '青元剑', 'quality' => 'legendary', 'patk' => 100, 'matk' => 80, 'rate' => 15, 'affixes' => ['patk' => 15]],
|
['type' => 'weapon', 'name' => '青元剑', 'quality' => 'legendary', 'patk' => 100, 'matk' => 80, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '虚天鼎碎片', 'rate' => 10, 'heal' => 2000], // 剧情物品作为高回复药
|
['type' => 'consume', 'name' => '虚天鼎碎片', 'rate' => 10, 'heal' => 2000], // 剧情物品作为高回复药
|
||||||
['type' => 'ring', 'name' => '黑煞戒', 'rate' => 20] + $ringTemplate,
|
['type' => 'ring', 'name' => '黑煞戒', 'rate' => 20] + $ringTemplate,
|
||||||
],
|
],
|
||||||
|
|
@ -541,7 +541,7 @@ return [
|
||||||
'exp' => 2500,
|
'exp' => 2500,
|
||||||
'spirit_stones' => 1000,
|
'spirit_stones' => 1000,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '天都尸火', 'quality' => 'legendary', 'matk' => 300, 'rate' => 15, 'affixes' => ['critdmg' => 20]],
|
['type' => 'weapon', 'name' => '天都尸火', 'quality' => 'legendary', 'matk' => 300, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '补天丹', 'rate' => 10, 'heal' => 3000],
|
['type' => 'consume', 'name' => '补天丹', 'rate' => 10, 'heal' => 3000],
|
||||||
['type' => 'necklace', 'name' => '虚天鼎', 'quality' => 'legendary', 'hp' => 2000, 'rate' => 5],
|
['type' => 'necklace', 'name' => '虚天鼎', 'quality' => 'legendary', 'hp' => 2000, 'rate' => 5],
|
||||||
],
|
],
|
||||||
|
|
@ -597,7 +597,7 @@ return [
|
||||||
'exp' => 4000,
|
'exp' => 4000,
|
||||||
'spirit_stones' => 1500,
|
'spirit_stones' => 1500,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '金蛟剪', 'quality' => 'legendary', 'patk' => 300, 'matk' => 200, 'rate' => 15, 'affixes' => ['crit' => 15]],
|
['type' => 'weapon', 'name' => '金蛟剪', 'quality' => 'legendary', 'patk' => 300, 'matk' => 200, 'rate' => 15],
|
||||||
['type' => 'armor', 'name' => '金蛟鳞甲', 'quality' => 'legendary', 'pdef' => 180, 'mdef' => 120, 'rate' => 15],
|
['type' => 'armor', 'name' => '金蛟鳞甲', 'quality' => 'legendary', 'pdef' => 180, 'mdef' => 120, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '九曲灵参', 'rate' => 10, 'heal' => 5000],
|
['type' => 'consume', 'name' => '九曲灵参', 'rate' => 10, 'heal' => 5000],
|
||||||
],
|
],
|
||||||
|
|
@ -712,7 +712,7 @@ return [
|
||||||
'exp' => 10000,
|
'exp' => 10000,
|
||||||
'spirit_stones' => 5000,
|
'spirit_stones' => 5000,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '黑风旗', 'quality' => 'legendary', 'matk' => 800, 'rate' => 15, 'affixes' => ['matk' => 20]],
|
['type' => 'weapon', 'name' => '黑风旗', 'quality' => 'legendary', 'matk' => 800, 'rate' => 15],
|
||||||
['type' => 'armor', 'name' => '魔龙甲', 'quality' => 'legendary', 'pdef' => 350, 'mdef' => 250, 'rate' => 15],
|
['type' => 'armor', 'name' => '魔龙甲', 'quality' => 'legendary', 'pdef' => 350, 'mdef' => 250, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '万年灵乳', 'rate' => 20, 'heal' => 8000],
|
['type' => 'consume', 'name' => '万年灵乳', 'rate' => 20, 'heal' => 8000],
|
||||||
],
|
],
|
||||||
|
|
@ -771,7 +771,7 @@ return [
|
||||||
'exp' => 15000,
|
'exp' => 15000,
|
||||||
'spirit_stones' => 8000,
|
'spirit_stones' => 8000,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '八灵尺', 'quality' => 'legendary', 'matk' => 1200, 'rate' => 15, 'affixes' => ['crit' => 20]],
|
['type' => 'weapon', 'name' => '八灵尺', 'quality' => 'legendary', 'matk' => 1200, 'rate' => 15],
|
||||||
['type' => 'ring', 'name' => '雪晶珠', 'quality' => 'legendary', 'crit' => 15, 'rate' => 15],
|
['type' => 'ring', 'name' => '雪晶珠', 'quality' => 'legendary', 'crit' => 15, 'rate' => 15],
|
||||||
['type' => 'consume', 'name' => '回阳水', 'rate' => 10, 'heal' => 10000],
|
['type' => 'consume', 'name' => '回阳水', 'rate' => 10, 'heal' => 10000],
|
||||||
],
|
],
|
||||||
|
|
@ -827,7 +827,7 @@ return [
|
||||||
'exp' => 30000,
|
'exp' => 30000,
|
||||||
'spirit_stones' => 15000,
|
'spirit_stones' => 15000,
|
||||||
'drops' => [
|
'drops' => [
|
||||||
['type' => 'weapon', 'name' => '青竹蜂云剑', 'quality' => 'legendary', 'patk' => 1500, 'matk' => 1000, 'rate' => 20, 'affixes' => ['patk' => 30, 'crit' => 20]],
|
['type' => 'weapon', 'name' => '青竹蜂云剑', 'quality' => 'legendary', 'patk' => 1500, 'matk' => 1000, 'rate' => 20],
|
||||||
['type' => 'armor', 'name' => '五行甲', 'quality' => 'legendary', 'pdef' => 1000, 'mdef' => 1000, 'rate' => 20],
|
['type' => 'armor', 'name' => '五行甲', 'quality' => 'legendary', 'pdef' => 1000, 'mdef' => 1000, 'rate' => 20],
|
||||||
['type' => 'consume', 'name' => '飞升令', 'rate' => 100, 'heal' => 99999], // 象征性物品
|
['type' => 'consume', 'name' => '飞升令', 'rate' => 100, 'heal' => 99999], // 象征性物品
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ return [
|
||||||
'min_level' => 1,
|
'min_level' => 1,
|
||||||
'desc' => '韩立在七玄门最好的朋友,虽无灵根但武功高强。',
|
'desc' => '韩立在七玄门最好的朋友,虽无灵根但武功高强。',
|
||||||
'base_stats' => [
|
'base_stats' => [
|
||||||
'hp' => 100, 'patk' => 15, 'matk' => 5, 'pdef' => 5, 'mdef' => 3, 'crit' => 10, 'critdmg' => 130, 'growth' => 1.2
|
'maxHp' => 100, 'patk' => 15, 'matk' => 5, 'pdef' => 5, 'mdef' => 3, 'crit' => 10, 'critdmg' => 130
|
||||||
],
|
],
|
||||||
// 天赋权重:武功型,偏攻击和暴击
|
// 天赋权重:武功型,偏攻击和暴击
|
||||||
'talent_weights' => [
|
'talent_weights' => [
|
||||||
|
|
@ -122,7 +122,7 @@ return [
|
||||||
'min_level' => 50,
|
'min_level' => 50,
|
||||||
'desc' => '寄宿在虚天鼎中的妖族器灵,实为灵界银月狼族玲珑仙子分魂。',
|
'desc' => '寄宿在虚天鼎中的妖族器灵,实为灵界银月狼族玲珑仙子分魂。',
|
||||||
'base_stats' => [
|
'base_stats' => [
|
||||||
'hp' => 2000, 'patk' => 250, 'matk' => 150, 'pdef' => 100, 'mdef' => 80, 'crit' => 20, 'critdmg' => 180, 'growth' => 2.5
|
'maxHp' => 2000, 'patk' => 250, 'matk' => 150, 'pdef' => 100, 'mdef' => 80, 'crit' => 20, 'critdmg' => 180
|
||||||
],
|
],
|
||||||
// 天赋权重:妖族器灵,偏攻击和暴伤
|
// 天赋权重:妖族器灵,偏攻击和暴伤
|
||||||
'talent_weights' => [
|
'talent_weights' => [
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,12 @@ class Actor
|
||||||
*/
|
*/
|
||||||
public function heal(int $amount): int
|
public function heal(int $amount): int
|
||||||
{
|
{
|
||||||
$maxHp = $this->maxHp ?? ($this->baseHp ?? ($this->hp ?? 0));
|
$stats = $this->getStats();
|
||||||
$old = $this->hp ?? 0;
|
$maxHp = $stats['maxHp'];
|
||||||
$this->hp = min(($this->hp ?? 0) + $amount, $maxHp);
|
$oldHp = $this->hp;
|
||||||
return $this->hp - $old;
|
$this->hp = min($this->hp + $amount, $maxHp);
|
||||||
|
|
||||||
|
return $this->hp - $oldHp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fullHeal(): void
|
public function fullHeal(): void
|
||||||
|
|
@ -200,6 +202,7 @@ class Actor
|
||||||
// Base stats
|
// Base stats
|
||||||
$base = [
|
$base = [
|
||||||
'maxHp' => $this->maxHp ?? ($this->baseHp ?? ($this->hp ?? 0)),
|
'maxHp' => $this->maxHp ?? ($this->baseHp ?? ($this->hp ?? 0)),
|
||||||
|
'hp' => $this->hp,
|
||||||
'patk' => $this->patk ?? 0,
|
'patk' => $this->patk ?? 0,
|
||||||
'matk' => $this->matk ?? 0,
|
'matk' => $this->matk ?? 0,
|
||||||
'pdef' => $this->pdef ?? 0,
|
'pdef' => $this->pdef ?? 0,
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,14 @@ class Partner extends Actor
|
||||||
$this->exp = $data['exp'] ?? 0;
|
$this->exp = $data['exp'] ?? 0;
|
||||||
$this->maxExp = $data['maxExp'] ?? (int)(100 * pow(1.5, $this->level - 1));
|
$this->maxExp = $data['maxExp'] ?? (int)(100 * pow(1.5, $this->level - 1));
|
||||||
|
|
||||||
// 从 baseStats 提取属性(只在初始化时使用一次)
|
$this->patk = $data['patk'] ;
|
||||||
$baseStats = $data['baseStats'] ?? [];
|
$this->matk = $data['matk'] ;
|
||||||
$this->patk = $baseStats['patk'] ?? $baseStats['atk'] ?? 10;
|
$this->pdef = $data['pdef'] ;
|
||||||
$this->matk = $baseStats['matk'] ?? 5;
|
$this->mdef = $data['mdef'] ;
|
||||||
$this->pdef = $baseStats['pdef'] ?? $baseStats['def'] ?? 5;
|
$this->crit = $data['crit'] ;
|
||||||
$this->mdef = $baseStats['mdef'] ?? 3;
|
$this->critdmg = $data['critdmg'] ?? 130;
|
||||||
$this->crit = $baseStats['crit'] ?? 5;
|
$this->maxHp = $data['maxHp'];
|
||||||
$this->critdmg = $baseStats['critdmg'] ?? 150;
|
$this->hp = $data['hp'] ?? $data['maxHp'];
|
||||||
|
|
||||||
// 装备和天赋系统
|
// 装备和天赋系统
|
||||||
$this->equip = $data['equip'] ?? [];
|
$this->equip = $data['equip'] ?? [];
|
||||||
$this->talents = $data['talents'] ?? $this->talents;
|
$this->talents = $data['talents'] ?? $this->talents;
|
||||||
|
|
@ -41,11 +40,6 @@ class Partner extends Actor
|
||||||
$this->maxMana = $data['maxMana'] ?? 100;
|
$this->maxMana = $data['maxMana'] ?? 100;
|
||||||
$this->spells = $data['spells'] ?? $this->spells;
|
$this->spells = $data['spells'] ?? $this->spells;
|
||||||
$this->spellBooks = $data['spellBooks'] ?? $this->spellBooks;
|
$this->spellBooks = $data['spellBooks'] ?? $this->spellBooks;
|
||||||
|
|
||||||
// 计算属性并设置生命值
|
|
||||||
$stats = $this->getStats();
|
|
||||||
$this->maxHp = $stats['maxHp'];
|
|
||||||
$this->hp = $data['hp'] ?? $stats['maxHp'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -44,21 +44,6 @@ class Player extends Actor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复生命值,不超过上限
|
|
||||||
* @param int $amount 恢复量
|
|
||||||
* @return int 实际恢复量
|
|
||||||
*/
|
|
||||||
public function heal(int $amount): int
|
|
||||||
{
|
|
||||||
$stats = $this->getStats();
|
|
||||||
$maxHp = $stats['maxHp'];
|
|
||||||
|
|
||||||
$oldHp = $this->hp;
|
|
||||||
$this->hp = min($this->hp + $amount, $maxHp);
|
|
||||||
|
|
||||||
return $this->hp - $oldHp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学习法术
|
* 学习法术
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Game\Modules;
|
namespace Game\Modules;
|
||||||
|
|
||||||
use Game\Core\Game;
|
use Game\Core\Game;
|
||||||
|
|
@ -35,7 +36,7 @@ class NpcPanel
|
||||||
$this->game->output->writeln("目前没有故人可以拜访。");
|
$this->game->output->writeln("目前没有故人可以拜访。");
|
||||||
} else {
|
} else {
|
||||||
foreach ($availableNpcs as $index => $npc) {
|
foreach ($availableNpcs as $index => $npc) {
|
||||||
$idx = $index+1;
|
$idx = $index + 1;
|
||||||
$this->game->output->writeln("[{$idx}] {$npc['name']} <{$npc['title']}>");
|
$this->game->output->writeln("[{$idx}] {$npc['name']} <{$npc['title']}>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,8 +51,8 @@ class NpcPanel
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($availableNpcs[$choice-1])) {
|
if (isset($availableNpcs[$choice - 1])) {
|
||||||
$this->interact($availableNpcs[$choice-1]);
|
$this->interact($availableNpcs[$choice - 1]);
|
||||||
} else {
|
} else {
|
||||||
$this->game->output->writeln("无效选择");
|
$this->game->output->writeln("无效选择");
|
||||||
Screen::sleep(1);
|
Screen::sleep(1);
|
||||||
|
|
@ -92,7 +93,7 @@ class NpcPanel
|
||||||
$actionKeys = array_keys($actions);
|
$actionKeys = array_keys($actions);
|
||||||
|
|
||||||
foreach ($actionKeys as $idx => $key) {
|
foreach ($actionKeys as $idx => $key) {
|
||||||
$label = match($key) {
|
$label = match ($key) {
|
||||||
'talk' => '交谈',
|
'talk' => '交谈',
|
||||||
'gift' => '领取赠礼',
|
'gift' => '领取赠礼',
|
||||||
'trade' => '交易',
|
'trade' => '交易',
|
||||||
|
|
@ -116,8 +117,8 @@ class NpcPanel
|
||||||
|
|
||||||
if ($choice == 0) return;
|
if ($choice == 0) return;
|
||||||
|
|
||||||
if (isset($actionKeys[$choice-1])) {
|
if (isset($actionKeys[$choice - 1])) {
|
||||||
$actionType = $actionKeys[$choice-1];
|
$actionType = $actionKeys[$choice - 1];
|
||||||
$actionData = $actions[$actionType];
|
$actionData = $actions[$actionType];
|
||||||
$this->handleAction($actionType, $actionData, $npc);
|
$this->handleAction($actionType, $actionData, $npc);
|
||||||
Screen::pause($this->game->output);
|
Screen::pause($this->game->output);
|
||||||
|
|
@ -187,7 +188,7 @@ class NpcPanel
|
||||||
$this->game->output->writeln("[0] 取消");
|
$this->game->output->writeln("[0] 取消");
|
||||||
|
|
||||||
$choice = Input::ask($this->game->output, "购买: ");
|
$choice = Input::ask($this->game->output, "购买: ");
|
||||||
if (isset($items[$choice-1])) {
|
if (isset($items[$choice - 1])) {
|
||||||
$itemInfo = $items[$choice];
|
$itemInfo = $items[$choice];
|
||||||
if ($this->game->player->spiritStones >= $itemInfo['price']) {
|
if ($this->game->player->spiritStones >= $itemInfo['price']) {
|
||||||
$this->game->player->spiritStones -= $itemInfo['price'];
|
$this->game->player->spiritStones -= $itemInfo['price'];
|
||||||
|
|
@ -247,10 +248,9 @@ class NpcPanel
|
||||||
$matk = $stats['matk'] ?? 5;
|
$matk = $stats['matk'] ?? 5;
|
||||||
$pdef = $stats['pdef'] ?? $stats['def'] ?? 5;
|
$pdef = $stats['pdef'] ?? $stats['def'] ?? 5;
|
||||||
$mdef = $stats['mdef'] ?? 3;
|
$mdef = $stats['mdef'] ?? 3;
|
||||||
$this->game->output->writeln("生命: {$stats['hp']} 物攻: {$patk} 魔攻: {$matk}");
|
$this->game->output->writeln("生命: {$stats['maxHp']} 物攻: {$patk} 魔攻: {$matk}");
|
||||||
$this->game->output->writeln("物防: {$pdef} 魔防: {$mdef}");
|
$this->game->output->writeln("物防: {$pdef} 魔防: {$mdef}");
|
||||||
$this->game->output->writeln("暴击: {$stats['crit']}% 暴伤: {$stats['critdmg']}%");
|
$this->game->output->writeln("暴击: {$stats['crit']}% 暴伤: {$stats['critdmg']}%");
|
||||||
$this->game->output->writeln("成长: {$stats['growth']}x");
|
|
||||||
$this->game->output->writeln("==============================");
|
$this->game->output->writeln("==============================");
|
||||||
|
|
||||||
if ($cost > 0) {
|
if ($cost > 0) {
|
||||||
|
|
@ -277,9 +277,7 @@ class NpcPanel
|
||||||
'exp' => 0,
|
'exp' => 0,
|
||||||
'baseStats' => $npc['base_stats'],
|
'baseStats' => $npc['base_stats'],
|
||||||
'equip' => [],
|
'equip' => [],
|
||||||
'talentWeights' => $npc['talent_weights'] ?? [
|
...$npc['base_stats']
|
||||||
'hp' => 1, 'patk' => 1, 'matk' => 1, 'pdef' => 1, 'mdef' => 1, 'crit' => 1, 'critdmg' => 1
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$player->recruitPartner($partner);
|
$player->recruitPartner($partner);
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class PartnerPanel
|
||||||
$this->game->output->writeln("经验: {$this->cyan}{$partner->exp}/{$partner->maxExp}{$this->reset}");
|
$this->game->output->writeln("经验: {$this->cyan}{$partner->exp}/{$partner->maxExp}{$this->reset}");
|
||||||
$this->game->output->writeln("");
|
$this->game->output->writeln("");
|
||||||
$this->game->output->writeln("{$this->white}--- 属性 ---{$this->reset}");
|
$this->game->output->writeln("{$this->white}--- 属性 ---{$this->reset}");
|
||||||
$this->game->output->writeln("生命值: {$this->green}{$stats['maxHp']}{$this->reset}");
|
$this->game->output->writeln("生命值: {$this->red}{$stats['hp']}{$this->reset}/{$stats['maxHp']}");
|
||||||
$this->game->output->writeln("物理攻击: {$this->red}{$stats['patk']}{$this->reset}");
|
$this->game->output->writeln("物理攻击: {$this->red}{$stats['patk']}{$this->reset}");
|
||||||
$this->game->output->writeln("魔法攻击: {$this->cyan}{$stats['matk']}{$this->reset}");
|
$this->game->output->writeln("魔法攻击: {$this->cyan}{$stats['matk']}{$this->reset}");
|
||||||
$this->game->output->writeln("物理防御: {$this->red}{$stats['pdef']}{$this->reset}");
|
$this->game->output->writeln("物理防御: {$this->red}{$stats['pdef']}{$this->reset}");
|
||||||
|
|
|
||||||
43
test/Test.php
Normal file
43
test/Test.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$play = new \Game\Entities\Partner(json_decode(' {
|
||||||
|
"id": "li_feiyu",
|
||||||
|
"name": "厉飞雨",
|
||||||
|
"level": 10,
|
||||||
|
"exp": 0,
|
||||||
|
"maxExp": 100,
|
||||||
|
"equip": [],
|
||||||
|
"talents": {
|
||||||
|
"hp": 0,
|
||||||
|
"patk": 0,
|
||||||
|
"matk": 0,
|
||||||
|
"pdef": 0,
|
||||||
|
"mdef": 0,
|
||||||
|
"crit": 0,
|
||||||
|
"critdmg": 0
|
||||||
|
},
|
||||||
|
"talentWeights": {
|
||||||
|
"hp": 1,
|
||||||
|
"patk": 1,
|
||||||
|
"matk": 1,
|
||||||
|
"pdef": 1,
|
||||||
|
"mdef": 1,
|
||||||
|
"crit": 1,
|
||||||
|
"critdmg": 1
|
||||||
|
},
|
||||||
|
"mana": 0,
|
||||||
|
"maxMana": 100,
|
||||||
|
"spells": [],
|
||||||
|
"spellBooks": [],
|
||||||
|
"hp": 100,
|
||||||
|
"maxHp": 100,
|
||||||
|
"patk": 15,
|
||||||
|
"matk": 5,
|
||||||
|
"pdef": 5,
|
||||||
|
"mdef": 3,
|
||||||
|
"crit": 10,
|
||||||
|
"critdmg": 130
|
||||||
|
}',true));
|
||||||
|
|
||||||
|
var_dump($play->getStats());
|
||||||
Loading…
Reference in New Issue
Block a user