-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
121 changed files
with
558 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
using RabiRiichi.Core; | ||
using RabiRiichi.Generated.Actions; | ||
using System.Collections.Generic; | ||
|
||
using System.Linq; | ||
|
||
namespace RabiRiichi.Actions { | ||
public class ChiiAction : ChooseTilesAction { | ||
public override string name => "chii"; | ||
public ChiiAction(int playerId, List<List<GameTile>> tiles, int priorityDelta = 0) : base(playerId, tiles) { | ||
priority = ActionPriority.Chii + priorityDelta; | ||
} | ||
|
||
public ChiiActionMsg ToProto() { | ||
var ret = new ChiiActionMsg(); | ||
ret.TileGroups.AddRange(options.Select(o => | ||
MenLike.From(((ChooseTilesActionOption)o).tiles).ToProto())); | ||
return ret; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
using RabiRiichi.Core; | ||
using RabiRiichi.Generated.Actions; | ||
using System.Collections.Generic; | ||
|
||
using System.Linq; | ||
|
||
namespace RabiRiichi.Actions { | ||
public class PonAction : ChooseTilesAction { | ||
public override string name => "pon"; | ||
public PonAction(int playerId, List<List<GameTile>> tiles, int priorityDelta = 0) : base(playerId, tiles) { | ||
priority = ActionPriority.Pon + priorityDelta; | ||
} | ||
|
||
public PonActionMsg ToProto() { | ||
var ret = new PonActionMsg(); | ||
ret.TileGroups.AddRange(options.Select(o => | ||
MenLike.From(((ChooseTilesActionOption)o).tiles).ToProto())); | ||
return ret; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using RabiRiichi.Core; | ||
using RabiRiichi.Generated.Core; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
using RabiRiichi.Generated.Actions; | ||
|
||
namespace RabiRiichi.Actions { | ||
public class SkipAction : ConfirmAction { | ||
public override string name => "skip"; | ||
|
||
public SkipAction(int playerId, int priorityDelta = 0) : base(playerId) { | ||
priority = ActionPriority.Skip + priorityDelta; | ||
} | ||
|
||
public virtual SkipActionMsg ToProto() { | ||
return new SkipActionMsg(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using RabiRiichi.Actions; | ||
using RabiRiichi.Events; | ||
using RabiRiichi.Events.InGame; | ||
using RabiRiichi.Generated.Actions; | ||
using RabiRiichi.Generated.Events; | ||
using System; | ||
|
||
namespace RabiRiichi.Communication.Proto { | ||
public static class ProtoConverters { | ||
public static PlayerActionMsg ToProto(IPlayerAction action) { | ||
var ret = new PlayerActionMsg(); | ||
if (action is AgariAction agariAction) { | ||
ret.AgariAction = agariAction.ToProto(); | ||
} else if (action is ChiiAction chiiAction) { | ||
ret.ChiiAction = chiiAction.ToProto(); | ||
} else if (action is PonAction ponAction) { | ||
ret.PonAction = ponAction.ToProto(); | ||
} else if (action is KanAction kanAction) { | ||
ret.KanAction = kanAction.ToProto(); | ||
} else if (action is RiichiAction riichiAction) { | ||
ret.RiichiAction = riichiAction.ToProto(); | ||
} else if (action is RyuukyokuAction ryuukyokuAction) { | ||
ret.RyuukyokuAction = ryuukyokuAction.ToProto(); | ||
} else if (action is PlayTileAction playTileAction) { | ||
ret.PlayTileAction = playTileAction.ToProto(); | ||
} else if (action is SkipAction skipAction) { | ||
ret.SkipAction = skipAction.ToProto(); | ||
} else { | ||
throw new ArgumentException($"Unknown action type: {action.GetType()}"); | ||
} | ||
return ret; | ||
} | ||
|
||
public static EventMsg ToProto(EventBase ev, int playerId) { | ||
var ret = new EventMsg(); | ||
if (ev is AddKanEvent addKanEvent) { | ||
ret.AddKanEvent = addKanEvent.ToProto(); | ||
} else if (ev is AddTileEvent addTileEvent) { | ||
ret.AddTileEvent = addTileEvent.ToProto(playerId); | ||
} else if (ev is AgariEvent agariEvent) { | ||
ret.AgariEvent = agariEvent.ToProto(); | ||
} else if (ev is ApplyScoreEvent applyScoreEvent) { | ||
ret.ApplyScoreEvent = applyScoreEvent.ToProto(); | ||
} else if (ev is BeginGameEvent beginGameEvent) { | ||
ret.BeginGameEvent = beginGameEvent.ToProto(); | ||
} else if (ev is CalcScoreEvent calcScoreEvent) { | ||
ret.CalcScoreEvent = calcScoreEvent.ToProto(); | ||
} else if (ev is ClaimTileEvent claimTileEvent) { | ||
ret.ClaimTileEvent = claimTileEvent.ToProto(); | ||
} else if (ev is ConcludeGameEvent concludeGameEvent) { | ||
ret.ConcludeGameEvent = concludeGameEvent.ToProto(); | ||
} else if (ev is DealerFirstTurnEvent dealerFirstTurnEvent) { | ||
ret.DealerFirstTurnEvent = dealerFirstTurnEvent.ToProto(playerId); | ||
} else if (ev is DealHandEvent dealHandEvent) { | ||
ret.DealHandEvent = dealHandEvent.ToProto(); | ||
} else if (ev is DiscardTileEvent discardTileEvent) { | ||
ret.DiscardTileEvent = discardTileEvent.ToProto(playerId); | ||
} else if (ev is DrawTileEvent drawTileEvent) { | ||
ret.DrawTileEvent = drawTileEvent.ToProto(playerId); | ||
} else if (ev is IncreaseJunEvent increaseJunEvent) { | ||
ret.IncreaseJunEvent = increaseJunEvent.ToProto(); | ||
} else if (ev is KanEvent kanEvent) { | ||
ret.KanEvent = kanEvent.ToProto(); | ||
} else if (ev is LateClaimTileEvent lateClaimTileEvent) { | ||
ret.LateClaimTileEvent = lateClaimTileEvent.ToProto(); | ||
} else if (ev is NextGameEvent nextGameEvent) { | ||
ret.NextGameEvent = nextGameEvent.ToProto(); | ||
} else if (ev is NextPlayerEvent nextPlayerEvent) { | ||
ret.NextPlayerEvent = nextPlayerEvent.ToProto(); | ||
} else if (ev is RevealDoraEvent revealDoraEvent) { | ||
ret.RevealDoraEvent = revealDoraEvent.ToProto(); | ||
} else if (ev is RyuukyokuEvent ryuukyokuEvent) { | ||
ret.RyuukyokuEvent = ryuukyokuEvent.ToProto(); | ||
} else if (ev is SetFuritenEvent setFuritenEvent) { | ||
ret.SetFuritenEvent = setFuritenEvent.ToProto(); | ||
} else if (ev is SetIppatsuEvent setIppatsuEvent) { | ||
ret.SetIppatsuEvent = setIppatsuEvent.ToProto(); | ||
} else if (ev is SetMenzenEvent setMenzenEvent) { | ||
ret.SetMenzenEvent = setMenzenEvent.ToProto(); | ||
} else if (ev is SetRiichiEvent setRiichiEvent) { | ||
ret.SetRiichiEvent = setRiichiEvent.ToProto(); | ||
} else if (ev is StopGameEvent stopGameEvent) { | ||
ret.StopGameEvent = stopGameEvent.ToProto(); | ||
} else if (ev is SyncGameStateEvent syncGameStateEvent) { | ||
ret.SyncGameStateEvent = syncGameStateEvent.ToProto(playerId); | ||
} else { | ||
throw new ArgumentException($"Unknown event type: {ev.GetType()}"); | ||
} | ||
return ret; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.