PHSPOWER.cs 1.3 KB

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