Skip to content

Commit

Permalink
JSON serialization bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KCFindstr committed Jul 22, 2022
1 parent dfed0d2 commit 36a714b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion Actions/KanAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Generic;

namespace RabiRiichi.Actions {
[RabiPrivate]
public class KanAction : ChooseTilesAction {
public override string name => "kan";
public KanAction(int playerId, List<List<GameTile>> tiles, int priorityDelta = 0) : base(playerId, tiles) {
Expand Down
3 changes: 2 additions & 1 deletion Actions/PlayerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public interface IPlayerAction : IRabiPlayerMessage {
}

/// <summary> 等待玩家做出选择 </summary>
[RabiMessage]
[RabiPrivate]
public abstract class PlayerAction<T> : IPlayerAction {
[RabiPrivate] public abstract string name { get; }

[RabiPrivate] public int playerId { get; init; }
public int playerId { get; init; }

public int priority { get; protected set; }

Expand Down
8 changes: 7 additions & 1 deletion Actions/SinglePlayerInquiry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

namespace RabiRiichi.Actions {
[RabiMessage]
[RabiPrivate]
public class SinglePlayerInquiry : IRabiPlayerMessage {
[RabiBroadcast] public readonly List<IPlayerAction> actions = new();
public readonly List<IPlayerAction> actions = new();
/// <summary>
/// 仅用于Json序列化,不应该被直接使用
/// </summary>
[RabiBroadcast] private List<object> acts => actions.ConvertAll(a => a as object);

public int playerId { get; init; }
/// <summary>
/// 所有操作的最高优先级
Expand Down
2 changes: 2 additions & 0 deletions Events/InitGameEvent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using RabiRiichi.Communication;
using RabiRiichi.Core;
using RabiRiichi.Events.InGame;
using System.Threading.Tasks;


namespace RabiRiichi.Events {
[RabiIgnore]
public class InitGameEvent : EventBase {
public override string name => "init";
public InitGameEvent(Game game) : base(game) { }
Expand Down
4 changes: 1 addition & 3 deletions Utils/Graphs/ProducerGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,9 @@ public bool UpdatePredecessor(int index, NodeContext predecessor) {
}

public IEnumerable<NodeContext> GetPath(int timeStamp) {
if (IsInput || IsVisited(timeStamp)) {
if (IsInput || !SetVisited(timeStamp)) {
yield break;
}
// Reuse this timestamp, but no need to reset node
visitedTimeStamp = timeStamp;
foreach (var path in predecessors.SelectMany(x => x.GetPath(timeStamp))) {
yield return path;
}
Expand Down

0 comments on commit 36a714b

Please sign in to comment.