public static ButtonCondition ReadButtonCondition(this ISwfStreamReader reader) { var res = new ButtonCondition { IdleToOverDown = reader.ReadBit(), OutDownToIdle = reader.ReadBit(), OutDownToOverDown = reader.ReadBit(), OverDownToOutDown = reader.ReadBit(), OverDownToOverUp = reader.ReadBit(), OverUpToOverDown = reader.ReadBit(), OverUpToIdle = reader.ReadBit(), IdleToOverUp = reader.ReadBit(), KeyPress = (byte)reader.ReadUnsignedBits(7), OverDownToIdle = reader.ReadBit() }; var ar = new ActionReader(reader); ActionBase action; do { action = ar.ReadAction(); res.Actions.Add(action); } while (!(action is ActionEnd)); return(res); }
public void Sanity() { Mock <MovementDisplayNamesResolver> movementDisplayNamesResolver = new Mock <MovementDisplayNamesResolver>(MockBehavior.Strict, new object[] { null }); Mock <LegalMovesCalculator> legalMovesCalculator = new Mock <LegalMovesCalculator>(); Mock <IO.IO> io = new Mock <IO.IO>(); string endGameSymbol = RandomString(100); string newGameSymbol = RandomString(100); string movements = RandomString(100); string expectedResponse = RandomString(100); ActionReader actionReader = new ActionReader(newGameSymbol, endGameSymbol, movementDisplayNamesResolver.Object, legalMovesCalculator.Object, io.Object); legalMovesCalculator.Setup(lmc => lmc.GetLegalMoves(It.IsAny <Board>())).Returns(new List <Movement>()); movementDisplayNamesResolver.Setup(mdnr => mdnr.Render(It.IsAny <List <Movement> >())).Returns(movements); io.Setup(o => o.Read(Match.Create <string>(msg => msg.Contains(endGameSymbol) && msg.Contains(newGameSymbol) && msg.Contains(movements)))) .Returns(expectedResponse); string response = actionReader.ReadAction(new Board()); Assert.Equal(expectedResponse, response); }
public static ClipActionRecord ReadClipActionRecord(this ISwfStreamReader reader, byte swfVersion) { var record = new ClipActionRecord(); record.Flags = reader.ReadClipEventFlags(swfVersion); if (record.Flags.IsEmpty) { return(record); } var offset = reader.ReadUInt32(); if (record.Flags.ClipEventKeyPress) { record.KeyCode = reader.ReadByte(); } ActionBase action; var ar = new ActionReader(reader); do { action = ar.ReadAction(); record.Actions.Add(action); } while (!(action is ActionEnd)); return(record); }
SwfTagBase ISwfTagVisitor <ISwfStreamReader, SwfTagBase> .Visit(DoActionTag tag, ISwfStreamReader reader) { var actionReader = new ActionReader(reader); ActionBase action; do { action = actionReader.ReadAction(); tag.ActionRecords.Add(action); } while (!(action is ActionEnd)); return(tag); }
static void Main(string[] args) { var readInput = new ActionReader(); var player1 = new Player(PlayerType.Human, "test_player_1"); var player2 = new Player(PlayerType.Human, "test_player_2"); var players = new[] { player1, player2 }; var game = new Game(players, Round.Two); game.StartGame(); }
protected T ReadAction <T>(byte[] source) where T : ActionBase { var mem = new MemoryStream(); mem.Write(source, 0, source.Length); mem.Seek(0, SeekOrigin.Begin); var reader = new SwfStreamReader(mem); var actionReader = new ActionReader(reader); var action = actionReader.ReadAction(); Assert.AreEqual(mem.Length, mem.Position, "Should reach end of stream"); return((T)action); }
public Player(PlayerType playerType, string name, ActionReader actionReader) { PlayerType = playerType; Name = name; Random = new Random(); RolledDice = new int[6]; FixedDice = Enumerable.Repeat(false, 6).ToArray(); TotalNumberOfRolls = 0; Board = new Board(); CombinationList = new CombinationList(); ActionReader = actionReader; CombinationToPlay = CombinationType.Unknown; FirstAction = false; Round = Round.One; // PatternProbabilities - Load list of all possible pattern probabilities PatternProbabilities = GameUtility.CreatePatternProbabilitiesDictionary(); }
public void ReadOneByteActionsTest() { var vals = Enum.GetValues(typeof(ActionCode)); foreach (ActionCode type in vals) { if ((byte)type < 0x80) { var mem = new MemoryStream(); mem.WriteByte((byte)type); mem.Seek(0, SeekOrigin.Begin); var reader = new SwfStreamReader(mem); var actionReader = new ActionReader(reader); var action = actionReader.ReadAction(); Assert.IsNotNull(action); var actualType = action.ActionCode; Assert.AreEqual(type, actualType); Assert.AreEqual(1, mem.Position); } } }
public static ClipActionRecord ReadClipActionRecord(this ISwfStreamReader reader, byte swfVersion) { var record = new ClipActionRecord(); record.Flags = reader.ReadClipEventFlags(swfVersion); if (record.Flags.IsEmpty) return record; var offset = reader.ReadUInt32(); if (record.Flags.ClipEventKeyPress) { record.KeyCode = reader.ReadByte(); } ActionBase action; var ar = new ActionReader(reader); do { action = ar.ReadAction(); record.Actions.Add(action); } while (!(action is ActionEnd)); return record; }
public static ButtonCondition ReadButtonCondition(this ISwfStreamReader reader) { var res = new ButtonCondition { IdleToOverDown = reader.ReadBit(), OutDownToIdle = reader.ReadBit(), OutDownToOverDown = reader.ReadBit(), OverDownToOutDown = reader.ReadBit(), OverDownToOverUp = reader.ReadBit(), OverUpToOverDown = reader.ReadBit(), OverUpToIdle = reader.ReadBit(), IdleToOverUp = reader.ReadBit(), KeyPress = (byte)reader.ReadUnsignedBits(7), OverDownToIdle = reader.ReadBit() }; var ar = new ActionReader(reader); ActionBase action; do { action = ar.ReadAction(); res.Actions.Add(action); } while (!(action is ActionEnd)); return res; }
public DefaultRelationshipAnalyzer(String actionfilepath) { this.map = ActionReader.ReadFile(actionfilepath); }
void OnDestroy() { _instance = null; }
void Awake() { _instance = this; }
public PlayerAction NextAction() { // Round ends either by a player ending their turn voluntarily, assigning a combination or running out of rolls DisplayActionList(Round, FirstAction); var(action, param) = ActionReader.GetNextAction(Round, FirstAction); switch (action) { case PlayerAction.RollDice: RollDice(true); return(action); case PlayerAction.FixDice: FixDice(param); return(action); case PlayerAction.AssignCombination: if (TryAssignCombination(param[0])) { return(action); } else { return(PlayerAction.InvalidAction); }; case PlayerAction.PickCombinationToPlay: if (TryToSetCombinationToPlay(param[0])) { return(action); } else { return(PlayerAction.InvalidAction); }; case PlayerAction.ShowBoard: ShowBoard(); return(action); case PlayerAction.EndTurn: if (CombinationToPlay != CombinationType.Unknown) { Board.CurrentBoard[CombinationToPlay].Score = 0; Board.CurrentBoard[CombinationToPlay].Completed = true; } return(action); case PlayerAction.InvalidAction: Console.WriteLine("Invalid action!"); return(action); case PlayerAction.EndGame: return(action); case PlayerAction.EvaluateAllCombinations: EvaluateAllCombinations(); return(action); // Action for testing purposes case PlayerAction.AssignDice: RolledDice = param; EvaluateDice(); DisplayDice(); DisplayPossibleCombinations(CurrentPossibleCombinations); return(action); default: throw new Exception(); } }