Restructure loading of game
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta, Id("player_stats")]
|
||||
public partial record PlayerInitialState
|
||||
{
|
||||
[Save("currentHP")]
|
||||
public int CurrentHP { get; init; }
|
||||
[Save("maximumHP")]
|
||||
public int MaximumHP { get; init; }
|
||||
[Save("currentVT")]
|
||||
public int CurrentVT { get; init; }
|
||||
[Save("maximumVT")]
|
||||
public int MaximumVT { get; init; }
|
||||
[Save("currentExp")]
|
||||
public double CurrentExp { get; init; }
|
||||
[Save("currentLevel")]
|
||||
public int CurrentLevel { get; init; }
|
||||
[Save("currentAttack")]
|
||||
public int CurrentAttack { get; init; }
|
||||
[Save("bonusAttack")]
|
||||
public int BonusAttack { get; init; }
|
||||
[Save("maxAttack")]
|
||||
public int MaxAttack { get; init; }
|
||||
[Save("currentDefense")]
|
||||
public int CurrentDefense { get; init; }
|
||||
[Save("bonusDefense")]
|
||||
public int BonusDefense { get; init; }
|
||||
[Save("maxDefense")]
|
||||
public int MaxDefense { get; init; }
|
||||
[Save("expToNextLevel")]
|
||||
public int ExpToNextLevel { get; init; }
|
||||
[Save("luck")]
|
||||
public double Luck { get; init; }
|
||||
}
|
||||
@@ -1,37 +1,115 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
using Chickensoft.Collections;
|
||||
using Godot;
|
||||
|
||||
[Meta, Id("player_stats")]
|
||||
public partial record PlayerInitialState
|
||||
public class PlayerStats
|
||||
{
|
||||
[Save("currentHP")]
|
||||
public int CurrentHP { get; init; }
|
||||
[Save("maximumHP")]
|
||||
public int MaximumHP { get; init; }
|
||||
[Save("currentVT")]
|
||||
public int CurrentVT { get; init; }
|
||||
[Save("maximumVT")]
|
||||
public int MaximumVT { get; init; }
|
||||
[Save("currentExp")]
|
||||
public double CurrentExp { get; init; }
|
||||
[Save("currentLevel")]
|
||||
public int CurrentLevel { get; init; }
|
||||
[Save("currentAttack")]
|
||||
public int CurrentAttack { get; init; }
|
||||
[Save("bonusAttack")]
|
||||
public int BonusAttack { get; init; }
|
||||
[Save("maxAttack")]
|
||||
public int MaxAttack { get; init; }
|
||||
[Save("currentDefense")]
|
||||
public int CurrentDefense { get; init; }
|
||||
[Save("bonusDefense")]
|
||||
public int BonusDefense { get; init; }
|
||||
[Save("maxDefense")]
|
||||
public int MaxDefense { get; init; }
|
||||
[Save("expToNextLevel")]
|
||||
public int ExpToNextLevel { get; init; }
|
||||
[Save("luck")]
|
||||
public double Luck { get; init; }
|
||||
}
|
||||
public PlayerStats(AutoProp<int> currentHP,
|
||||
AutoProp<int> maximumHP,
|
||||
AutoProp<int> currentVT,
|
||||
AutoProp<int> maximumVT,
|
||||
AutoProp<int> currentAttack,
|
||||
AutoProp<int> maxAttack,
|
||||
AutoProp<int> bonusAttack,
|
||||
AutoProp<int> currentDefense,
|
||||
AutoProp<int> maxDefense,
|
||||
AutoProp<int> bonusDefense,
|
||||
AutoProp<double> currentExp,
|
||||
AutoProp<int> expToNextLevel,
|
||||
AutoProp<int> currentLevel,
|
||||
AutoProp<double> luck)
|
||||
{
|
||||
CurrentHP = currentHP;
|
||||
MaximumHP = maximumHP;
|
||||
CurrentVT = currentVT;
|
||||
MaximumVT = maximumVT;
|
||||
CurrentAttack = currentAttack;
|
||||
MaxAttack = maxAttack;
|
||||
BonusAttack = bonusAttack;
|
||||
CurrentDefense = currentDefense;
|
||||
MaxDefense = maxDefense;
|
||||
BonusDefense = bonusDefense;
|
||||
CurrentExp = currentExp;
|
||||
ExpToNextLevel = expToNextLevel;
|
||||
CurrentLevel = currentLevel;
|
||||
Luck = luck;
|
||||
}
|
||||
|
||||
public AutoProp<int> CurrentHP { get; init; }
|
||||
public AutoProp<int> MaximumHP { get; init; }
|
||||
public AutoProp<int> CurrentVT { get; init; }
|
||||
public AutoProp<int> MaximumVT { get; init; }
|
||||
public AutoProp<int> CurrentAttack { get; init; }
|
||||
public AutoProp<int> MaxAttack { get; init; }
|
||||
public AutoProp<int> BonusAttack { get; init; }
|
||||
public AutoProp<int> CurrentDefense { get; init; }
|
||||
public AutoProp<int> MaxDefense { get; init; }
|
||||
public AutoProp<int> BonusDefense { get; init; }
|
||||
public AutoProp<double> CurrentExp { get; init; }
|
||||
public AutoProp<int> ExpToNextLevel { get; init; }
|
||||
public AutoProp<int> CurrentLevel { get; init; }
|
||||
public AutoProp<double> Luck { get; init; }
|
||||
|
||||
public void SetCurrentHP(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumHP.Value);
|
||||
CurrentHP.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumHP(int newValue)
|
||||
{
|
||||
MaximumHP.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentVT(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumVT.Value);
|
||||
CurrentVT.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumVT(int newValue)
|
||||
{
|
||||
MaximumVT.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentExp(double newValue)
|
||||
{
|
||||
CurrentExp.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentLevel(int newValue)
|
||||
{
|
||||
CurrentLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentAttack(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxAttack.Value);
|
||||
CurrentAttack.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusAttack(int newValue)
|
||||
{
|
||||
BonusAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxAttack(int newValue)
|
||||
{
|
||||
MaxAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentDefense(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxDefense.Value);
|
||||
CurrentDefense.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusDefense(int newValue)
|
||||
{
|
||||
BonusDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxDefense(int newValue)
|
||||
{
|
||||
MaxDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetExpToNextLevel(int newValue)
|
||||
{
|
||||
ExpToNextLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetLuck(double newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, 1.0);
|
||||
Luck.OnNext(clampedValue);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Collections;
|
||||
using Godot;
|
||||
|
||||
public class PlayerStats
|
||||
{
|
||||
public PlayerStats(AutoProp<int> currentHP,
|
||||
AutoProp<int> maximumHP,
|
||||
AutoProp<int> currentVT,
|
||||
AutoProp<int> maximumVT,
|
||||
AutoProp<int> currentAttack,
|
||||
AutoProp<int> maxAttack,
|
||||
AutoProp<int> bonusAttack,
|
||||
AutoProp<int> currentDefense,
|
||||
AutoProp<int> maxDefense,
|
||||
AutoProp<int> bonusDefense,
|
||||
AutoProp<double> currentExp,
|
||||
AutoProp<int> expToNextLevel,
|
||||
AutoProp<int> currentLevel,
|
||||
AutoProp<double> luck)
|
||||
{
|
||||
CurrentHP = currentHP;
|
||||
MaximumHP = maximumHP;
|
||||
CurrentVT = currentVT;
|
||||
MaximumVT = maximumVT;
|
||||
CurrentAttack = currentAttack;
|
||||
MaxAttack = maxAttack;
|
||||
BonusAttack = bonusAttack;
|
||||
CurrentDefense = currentDefense;
|
||||
MaxDefense = maxDefense;
|
||||
BonusDefense = bonusDefense;
|
||||
CurrentExp = currentExp;
|
||||
ExpToNextLevel = expToNextLevel;
|
||||
CurrentLevel = currentLevel;
|
||||
Luck = luck;
|
||||
}
|
||||
|
||||
public AutoProp<int> CurrentHP { get; init; }
|
||||
public AutoProp<int> MaximumHP { get; init; }
|
||||
public AutoProp<int> CurrentVT { get; init; }
|
||||
public AutoProp<int> MaximumVT { get; init; }
|
||||
public AutoProp<int> CurrentAttack { get; init; }
|
||||
public AutoProp<int> MaxAttack { get; init; }
|
||||
public AutoProp<int> BonusAttack { get; init; }
|
||||
public AutoProp<int> CurrentDefense { get; init; }
|
||||
public AutoProp<int> MaxDefense { get; init; }
|
||||
public AutoProp<int> BonusDefense { get; init; }
|
||||
public AutoProp<double> CurrentExp { get; init; }
|
||||
public AutoProp<int> ExpToNextLevel { get; init; }
|
||||
public AutoProp<int> CurrentLevel { get; init; }
|
||||
public AutoProp<double> Luck { get; init; }
|
||||
|
||||
public void SetCurrentHP(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumHP.Value);
|
||||
CurrentHP.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumHP(int newValue)
|
||||
{
|
||||
MaximumHP.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentVT(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumVT.Value);
|
||||
CurrentVT.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumVT(int newValue)
|
||||
{
|
||||
MaximumVT.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentExp(double newValue)
|
||||
{
|
||||
CurrentExp.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentLevel(int newValue)
|
||||
{
|
||||
CurrentLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentAttack(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxAttack.Value);
|
||||
CurrentAttack.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusAttack(int newValue)
|
||||
{
|
||||
BonusAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxAttack(int newValue)
|
||||
{
|
||||
MaxAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentDefense(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxDefense.Value);
|
||||
CurrentDefense.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusDefense(int newValue)
|
||||
{
|
||||
BonusDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxDefense(int newValue)
|
||||
{
|
||||
MaxDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetExpToNextLevel(int newValue)
|
||||
{
|
||||
ExpToNextLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetLuck(double newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, 1.0);
|
||||
Luck.OnNext(clampedValue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user