PHSPOWER.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace OpenVIII.Fields.Scripts.Instructions
  2. {
  3. internal sealed class PHSPOWER : JsmInstruction
  4. {
  5. #region Fields
  6. private readonly bool _isPartySwitchEnabled;
  7. #endregion Fields
  8. #region Constructors
  9. public PHSPOWER(bool isPartySwitchEnabled) => _isPartySwitchEnabled = isPartySwitchEnabled;
  10. public PHSPOWER(int parameter, IStack<IJsmExpression> stack)
  11. : this(
  12. isPartySwitchEnabled: ((Jsm.Expression.PSHN_L)stack.Pop()).Boolean())
  13. {
  14. }
  15. #endregion Constructors
  16. #region Methods
  17. public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services) => sw.Format(formatterContext, services)
  18. .StaticType(nameof(IPartyService))
  19. .Property(nameof(IPartyService.IsPartySwitchEnabled))
  20. .Assign(_isPartySwitchEnabled)
  21. .Comment(nameof(PHSPOWER));
  22. public override IAwaitable TestExecute(IServices services)
  23. {
  24. ServiceId.Party[services].IsPartySwitchEnabled = _isPartySwitchEnabled;
  25. return DummyAwaitable.Instance;
  26. }
  27. public override string ToString() => $"{nameof(PHSPOWER)}({nameof(_isPartySwitchEnabled)}: {_isPartySwitchEnabled})";
  28. #endregion Methods
  29. }
  30. }