Ejemplo n.º 1
0
        /// <summary>
        /// Adds a SenseEvent object to the local JSON event storage.
        /// </summary>
        /// <param name="senseEvent">The SenseEvent object to store.</param>
        /// <remarks>Mind that only a certain amount of events will be persisted, configured via the private MaxRecords constant in this class.</remarks>
        public static void Add(SenseEvent senseEvent)
        {
            var storage = new JsonStorage($@"DataStorage\{senseEvent.SessionId}.json");
            var events  = storage.Deserialize <List <SenseEvent> >() ?? new List <SenseEvent>();

            events.Add(senseEvent);
            if (events.Count > MaxRecords)
            {
                events.RemoveAt(0);
            }

            storage.Serialize(events);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles posting a SenseEvent object, adding it to the local JSON event storage for the corresponding session.
        /// </summary>
        /// <param name="senseEvent">The SenseEvent object to store.</param>
        /// <returns>An IHttpActionResult object.</returns>
        public IHttpActionResult PostEvent(SenseEvent senseEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // save the latest frame capture to disk for the current session ID
            Imaging.SaveImage(senseEvent.SessionId, senseEvent.Capture);

            // remove the frame capture data from the event object
            senseEvent.Capture = null;

            // save the rest of the event data
            EventStorage.Add(senseEvent);

            return(Ok());
        }
Ejemplo n.º 3
0
        public bool ActOnSelection(IEnumerable<Combatant> targets)
        {
            Ally performer = AssociatedAlly;

            #region Attack

            if (_option == _attackOption)
            {
                performer.Attack(targets.First());
            }

            #endregion Attack

            #region 2x-Cut

            else if (_option == _doubleCutOption2)
            {
                performer.AttackX2(targets.First());
            }

            #endregion 2x-Cut

            #region 4x-Cut

            else if (_option == _doubleCutOption4)
            {
                performer.AttackX4(targets);
            }

            #endregion 4x-Cut

            #region Sense

            else if (_option == _senseOption)
            {
                BattleEvent sense = new SenseEvent(AssociatedAlly, targets);

                AssociatedAlly.CurrentBattle.EnqueueAction(sense);
            }

            #endregion Sense

            #region Mime

            else if (_option == _mimeOption)
            {
            //                if (AssociatedAlly.CurrentBattle.LastPartyAbility == null)
            //                {
            ////                    DisableActionHook(true);
            //                    AssociatedAlly.TurnTimer.Reset();
            //                }
            //                else
            //                {
            //                    AssociatedAlly.Ability = AssociatedAlly.CurrentBattle.LastPartyAbility;
            //                    try
            //                    {
            //                        AssociatedAlly.Ability.Performer = performer;
            //                    }
            //                    catch (Exception e)
            //                    {
            //                    }
            //                }
            }

            #endregion Mime

            #region Deathblow

            else if (_option == _deathblowOption)
            {
            //                DeathblowEvent e = DeathblowEvent.Create(AssociatedAlly, targets);
            //
            //                AssociatedAlly.CurrentBattle.EnqueueAction(e);
            }

            #endregion Deathblow

            #region Steal
            else if (_option == _stealOption)
            {
                StealEvent steal = new StealEvent(AssociatedAlly, targets);

                AssociatedAlly.CurrentBattle.EnqueueAction(steal);
            }
            #endregion Steal
            #region Mug
            else if (_option == _mugOption)
            {
            //                MugEvent e = MugEvent.Create(AssociatedAlly, targets);
            //
            //                AssociatedAlly.CurrentBattle.EnqueueAction(e);
            }
            #endregion Mug

            return true;
        }
Ejemplo n.º 4
0
 public void UpdateSenseEvents()
 {
     SenseEvent.UpdateSensors();
 }
Ejemplo n.º 5
0
        public bool ActOnSelection(IEnumerable <Combatant> targets)
        {
            Ally performer = AssociatedAlly;

            #region Attack

            if (_option == _attackOption)
            {
                performer.Attack(targets.First());
            }

            #endregion Attack


            #region 2x-Cut

            else if (_option == _doubleCutOption2)
            {
                performer.AttackX2(targets.First());
            }

            #endregion 2x-Cut

            #region 4x-Cut

            else if (_option == _doubleCutOption4)
            {
                performer.AttackX4(targets);
            }

            #endregion 4x-Cut

            #region Sense

            else if (_option == _senseOption)
            {
                BattleEvent sense = new SenseEvent(AssociatedAlly, targets);

                AssociatedAlly.CurrentBattle.EnqueueAction(sense);
            }

            #endregion Sense

            #region Mime

            else if (_option == _mimeOption)
            {
//                if (AssociatedAlly.CurrentBattle.LastPartyAbility == null)
//                {
////                    DisableActionHook(true);
//                    AssociatedAlly.TurnTimer.Reset();
//                }
//                else
//                {
//                    AssociatedAlly.Ability = AssociatedAlly.CurrentBattle.LastPartyAbility;
//                    try
//                    {
//                        AssociatedAlly.Ability.Performer = performer;
//                    }
//                    catch (Exception e)
//                    {
//                    }
//                }
            }

            #endregion Mime

            #region Deathblow

            else if (_option == _deathblowOption)
            {
//                DeathblowEvent e = DeathblowEvent.Create(AssociatedAlly, targets);
//
//                AssociatedAlly.CurrentBattle.EnqueueAction(e);
            }

            #endregion Deathblow

            #region Steal
            else if (_option == _stealOption)
            {
                StealEvent steal = new StealEvent(AssociatedAlly, targets);

                AssociatedAlly.CurrentBattle.EnqueueAction(steal);
            }
            #endregion Steal
            #region Mug
            else if (_option == _mugOption)
            {
//                MugEvent e = MugEvent.Create(AssociatedAlly, targets);
//
//                AssociatedAlly.CurrentBattle.EnqueueAction(e);
            }
            #endregion Mug

            return(true);
        }