【发布时间】:2021-07-23 06:31:33
【问题描述】:
我正在尝试实现一个简单的回合制游戏,在游戏开始前 N 名玩家可以加入游戏。游戏开始后,在每一轮中,每个玩家轮流掷一对骰子,以便他们加入游戏。比赛共有三轮。游戏结束时,每位玩家都会获得积分。
例如,假设玩家 P1、P2、P3、P4 以该顺序加入游戏,那么他们将按照相同的顺序滚动这对骰子。三轮后,假设结果为
P1: (3,5), (4,1), (2,3)
P2: (5,5), (4,3), (1,3)
P3: (3,3), (4,4), (2,1)
对于游戏,我的想法是:
public interface IGameBase : IGrainWithGuidKey
{
Task<bool> IsActive();
Task Join(IPlayerBase player);
Task Leave(IPlayerBase player);
}
public interface IGame<TState, in TRequest> : IGameBase
{
Task<TState> State();
Task<TState> Play(IPlayerBase player, TRequest request);
}
public interface IPlayerBase : IGrainWithGuidCompoundKey
{
Task<IPlayerInfo> Info();
Task<IEnumerable<Guid>> Games();
Task Subscribe(IGameBase game);
Task Unsubscribe(IGameBase game);
}
我应该如何实现让玩家知道该轮到他们玩了?
【问题讨论】:
标签: orleans