[TestCase] public void CancelsPriority()
            {
                rules[TestStatus.A].Aggregator = rules.Bool;
                string message = null;

                rules[TestStatus.A].Messages.Decreased = (obj, st, ov, nv) => {
                    message = "Status A is no longer true";
                };
                var s = new StatusInstance <TestObj> [4];

                for (int i = 0; i < 4; ++i)
                {
                    int ii = i;
                    s[i] = new StatusInstance <TestObj>((int)TestStatus.A, cancelPriority: ii * ii, overrideSetIndex: i);                  //0, 1, 4, & 9 priority

                    rules.GetOverrideSet(i).Overrides(TestStatus.A).Messages.Decreased = (obj, st, ov, nv) => {
                        message = $"Status A is no longer true: Instance {ii}";
                    };
                }
                tracker.AddStatusInstance(s[1]);                 // Order of addition doesn't matter
                tracker.AddStatusInstance(s[3]);
                tracker.AddStatusInstance(s[0]);
                tracker.AddStatusInstance(s[2]);
                tracker.Cancel(TestStatus.A);
                Assert.AreEqual("Status A is no longer true: Instance 3", message);
                // Highest priority was last to be removed, and was the only one to actually change the
                // value (because of the boolean aggregator)
            }
            [TestCase] public void SerializeWithCallback()
            {
                rules[TestStatus.A].Feeds(TestStatus.B);
                rules[TestStatus.B].Suppresses(TestStatus.C);
                rules[TestStatus.B].Aggregator = rules.Bool;
                tracker.Add(TestStatus.A, 2);
                tracker.Add(TestStatus.C, 1);                 // A==2, B==1, C==0

                byte[] bytes;
                using (System.IO.MemoryStream stream = new MemoryStream()) {
                    tracker.Serialize(stream, SerializeCallback);
                    bytes = stream.ToArray();
                }
                Assert.IsNull(deserializedInstanceA);
                StatusTracker <TestObj, TestStatus> tracker2;

                using (System.IO.MemoryStream stream = new MemoryStream(bytes)) {
                    tracker2 = rules.CreateStatusTracker(testObj);
                    tracker2.Deserialize(stream, DeserializeCallback);
                }
                Assert.IsNotNull(deserializedInstanceA);
                Assert.AreEqual(2, tracker2[TestStatus.A]);
                Assert.AreEqual(1, tracker2[TestStatus.B]);
                Assert.AreEqual(0, tracker2[TestStatus.C]);
                deserializedInstanceA.Value = 7;              // Make sure that it still responds properly to instance value changes.
                Assert.AreEqual(7, tracker2[TestStatus.A]);
                deserializedInstanceA = null;                 //cleanup to be safe
            }
            [TestCase] public void LoneStatusInstance()
            {
                StatusInstance <TestObj> instance = tracker.CreateStatusInstance(TestStatus.C, value: 6, cancelPriority: 3, type: InstanceType.Prevent, overrideSetIndex: -2);

                byte[] bytes;
                using (System.IO.MemoryStream stream = new MemoryStream()) {
                    instance.Serialize(stream);
                    bytes = stream.ToArray();
                }
                StatusInstance <TestObj> instance2;

                using (System.IO.MemoryStream stream = new MemoryStream(bytes)) {
                    instance2 = StatusInstance <TestObj> .Deserialize(stream);
                }
                byte[] bytes2;
                using (System.IO.MemoryStream stream = new MemoryStream()) {
                    instance2.Serialize(stream);
                    bytes2 = stream.ToArray();
                }
                Assert.AreEqual(bytes.Length, bytes2.Length, "Byte array lengths did not match");
                for (int i = 0; i < bytes.Length; ++i)
                {
                    Assert.AreEqual(bytes[i], bytes2[i], $"Byte array differs at index {i}");
                }
            }
Beispiel #4
0
 public StatusEvent(BattleEvent eventInfo, Status baseStatus, StatusInstance currentStatus, BattleAgent target)
 {
     Event  = eventInfo;
     Base   = baseStatus;
     Status = currentStatus;
     Target = target;
 }
Beispiel #5
0
        /// <summary>
        /// 检测选择框是否能用
        /// </summary>
        private void checkCheckBoxes()
        {
            var _in = StatusInstance.Find(f => f.IsItInventory == true);

            cbIsInventory.Enabled = null == _in;

            var wait = StatusInstance.Find(f => f.IsItWaiting == true);

            cbIsWaiting.Enabled = null == wait;

            var _out = StatusInstance.Find(f => f.IsItOutstorage == true);

            cbIsOutstorage.Enabled = null == _out;

            var over = StatusInstance.Find(f => f.IsItOverhaul == true);

            cbIsOverhaul.Enabled = null == over;

            var rental = StatusInstance.Find(f => f.IsItRental == true);

            cbIsRental.Enabled = null == rental;

            var testing = StatusInstance.Find(f => f.IsItTesting == true);

            cbIsTesting.Enabled = null == testing;

            var normal = StatusInstance.Find(f => f.IsItVehicle == true);

            cbIsNormal.Enabled = null == normal;
        }
Beispiel #6
0
 private void Exhaust(StatusInstance status, BattleAgent target)
 {
     if (status.Exhaustible && status["Duration"] <= 0)
     {
         target.StatusEffects.Remove(this);
     }
 }
 private void DeserializeCallback(System.IO.BinaryReader reader, StatusInstance <TestObj> instance, TestObj obj)
 {
     Assert.AreEqual("hello", reader.ReadString());
     Assert.AreEqual(true, reader.ReadBoolean());
     if (instance.GetStatus <TestStatus>() == TestStatus.A)
     {
         deserializedInstanceA = instance;
     }
 }
Beispiel #8
0
        protected void btCheckoutStorage_Click(object sender, EventArgs e)
        {
            var id        = int.Parse(hidCheckEquipmentId.Value);
            var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null == equipment)
            {
                ShowNotification("./equipment_checkout.aspx", "Cannot find the equipment.", false);
                //return;
            }
            else
            {
                DateTime begin;
                try { begin = DateTime.Parse(outTime.Value.Trim()); }
                catch { begin = DateTime.Now; }

                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    // 出厂时,如果是普通车辆,则直接划为车辆状态,不参与出库/入库流程
                    if (act.TB_EquipmentModel.TB_EquipmentType.IsVehicle == true)
                    {
                        act.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                    }
                    else
                    {
                        act.Status = int.Parse(ddlOuttype.SelectedValue);
                    }
                    act.Customer = int.Parse(hidCheckCustomerId.Value);
                    // 出库时的总运转时间
                    act.OutdoorWorktime = equipment.Runtime;
                    // 出库的时间
                    act.OutdoorTime = begin;
                    // 出库后库存信息置为null
                    act.Warehouse = null;
                });
                equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                // 保存出库历史记录
                var history = StoreInstance.GetObject();
                history.Equipment = equipment.id;
                history.Status    = equipment.Status;
                history.Stocktime = begin;
                // 设备的出入库次数,入库时增1,出库时不变
                history.StoreTimes = equipment.StoreTimes;
                history.Warehouse  = null;
                StoreInstance.Add(history);

                // 保存操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("Deliver")).id,
                    ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                               " check out(" + ddlOuttype.SelectedItem.Text + ") to: " + equipment.TB_Customer.Name
                });

                ShowNotification("./equipment_checkout.aspx", "\"" + EquipmentInstance.GetFullNumber(equipment) + "\" has delivered.");
            }
        }
            public void GetValue()
            {
                var instance = new StatusInstance <TestObj>(7);                // 7 is defined for TestStatus

                Assert.AreEqual(TestStatus.D, instance.GetStatus <TestStatus>());

                var instance2 = new StatusInstance <TestObj>(8);                // 8 is not defined for TestStatus

                Assert.AreEqual((TestStatus)8, instance2.GetStatus <TestStatus>());
            }
Beispiel #10
0
        private void ShowEdit()
        {
            var s = StatusInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != s)
            {
                txtCode.Value         = s.Code;
                txtName.Value         = s.Name;
                cbIsInventory.Checked = s.IsItInventory.Value;
                if (s.IsItInventory == true)
                {
                    cbIsInventory.Enabled = true;
                }

                cbIsOutstorage.Checked = s.IsItOutstorage.Value;
                if (s.IsItOutstorage == true)
                {
                    cbIsOutstorage.Enabled = true;
                }

                cbIsOverhaul.Checked = s.IsItOverhaul.Value;
                if (s.IsItOverhaul == true)
                {
                    cbIsOverhaul.Enabled = true;
                }

                cbIsWaiting.Checked = s.IsItWaiting.Value;
                if (s.IsItWaiting == true)
                {
                    cbIsWaiting.Enabled = true;
                }

                cbIsRental.Checked = s.IsItRental.Value;
                if (s.IsItRental == true)
                {
                    cbIsRental.Enabled = true;
                }

                cbIsTesting.Checked = s.IsItTesting.Value;
                if (s.IsItTesting == true)
                {
                    cbIsTesting.Enabled = true;
                }

                cbIsNormal.Checked = s.IsItVehicle.Value;
                if (s.IsItVehicle == true)
                {
                    cbIsNormal.Enabled = true;
                }
            }
            else
            {
                ShowNotification("./equipment_status.aspx", "Error: Cannot edit null object of <a>Equipment Status</a>.", false);
            }
        }
Beispiel #11
0
        protected void confirmRental_Click(object sender, EventArgs e)
        {
            // 租赁出库
            if (!HasSessionLose)
            {
                var id        = ParseInt(Utility.Decrypt(hiddenRentalId.Value));
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_rental.aspx", "Cannot find the equipment.", false);
                }
                else
                {
                    DateTime begin;
                    try { begin = DateTime.Parse(beginAt.Value.Trim()); }
                    catch { begin = DateTime.Now; }

                    EquipmentInstance.Update(f => f.id == equipment.id, act =>
                    {
                        act.Status          = StatusInstance.Find(f => f.IsItRental == true).id;
                        act.Customer        = int.Parse(hiddenCustomer.Value);
                        act.OutdoorTime     = begin;
                        act.OutdoorWorktime = equipment.Runtime;
                        act.Warehouse       = null;
                        act.ReclaimTime     = DateTime.Parse(deadLine.Value + " 00:00:00");
                    });

                    equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                    // 保存出库历史记录
                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    history.Status    = equipment.Status;
                    history.Stocktime = begin;
                    // 设备的出入库次数,入库时增1,出库时不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = (int?)null;
                    StoreInstance.Add(history);

                    // 保存操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Rental")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                                   " rent to: " + equipment.TB_Customer.Name + ", " +
                                   equipment.OutdoorTime.Value.ToString("yyyy/MM/dd") +
                                   " to " + equipment.ReclaimTime.Value.ToString("yyyy/MM/dd")
                    });

                    ShowNotification("./equipment_rental.aspx", "\"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" has rent to " + equipment.TB_Customer.Name + ".");
                }
            }
        }
            [TestCase] public void TryGetValue()
            {
                var        instance = new StatusInstance <TestObj>(7);         // 7 is defined for TestStatus
                TestStatus status;

                Assert.True(instance.TryGetStatus(out status));
                Assert.AreEqual(TestStatus.D, status);

                var instance2 = new StatusInstance <TestObj>(8);                // 8 is not defined for TestStatus

                Assert.False(instance2.TryGetStatus(out status));               // Returns false, no exception
            }
        private void SaveNewEquipment()
        {
            var value     = hidNewInstorage.Value;
            var equipment = JsonConverter.ToObject <TB_Equipment>(value);
            // 查找是否有相同型号的相同设备号码
            var exist = EquipmentInstance.Find(f => f.Model == equipment.Model && f.Number.Equals(equipment.Number) && f.Deleted == false);

            if (null == exist)
            {
                var model  = ModelInstance.Find(f => f.id == equipment.Model);
                var newOne = EquipmentInstance.GetObject();
                newOne.Model = equipment.Model;
                if (model.TB_EquipmentType.IsVehicle == true)
                {
                    // 新增的设备是普通车辆时,直接划为车辆,不参与出库/入库流程
                    newOne.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                }
                else
                {
                    newOne.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                }
                newOne.Warehouse  = equipment.Warehouse;
                newOne.Number     = equipment.Number;
                newOne.StoreTimes = equipment.StoreTimes;
                newOne.Functional = equipment.Functional;
                newOne            = EquipmentInstance.Add(newOne);

                // 保存入库信息
                var history = StoreInstance.GetObject();
                history.Equipment = newOne.id;
                history.Status    = newOne.Status;
                history.Stocktime = DateTime.Parse(inDate.Value);
                // 默认第1次入库
                history.StoreTimes = newOne.StoreTimes;
                history.Warehouse  = newOne.Warehouse;
                StoreInstance.Add(history);

                // 保存入库操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("InStore")).id,
                    ObjectA  = EquipmentInstance.ToString(newOne)
                });

                ShowNotification("./equipment_new_product.aspx",
                                 "New equipment \"" + EquipmentInstance.GetFullNumber(exist) + "\" has been saved.");
            }
            else
            {
                ShowNotification("./equipment_new_product.aspx",
                                 "There has a same number of \"" + EquipmentInstance.GetFullNumber(exist) + "\" exist.", false);
            }
        }
Beispiel #14
0
 protected void bt_Test_Click(object sender, EventArgs e)
 {
     if (!HasSessionLose)
     {
         if ("" != hidID.Value)
         {
             var id       = int.Parse(Utility.Decrypt(hidID.Value));
             var terminal = TerminalInstance.Find(f => f.id == id && f.Delete == false);
             if (null != terminal)
             {
                 if (terminal.HasBound.Value == false)
                 {
                     ShowNotification("./terminal_list.aspx", "No equipment bind on this terminal.", false);
                 }
                 else
                 {
                     var test = StatusInstance.Find(f => f.IsItTesting == true);
                     if (null == test)
                     {
                         ShowNotification("Situation code is not exist.", "", false);
                     }
                     else
                     {
                         var equip = terminal.TB_Equipment.FirstOrDefault();
                         if (null != equip)
                         {
                             EquipmentInstance.Update(f => f.id == equip.id, act =>
                             {
                                 act.Status = StatusInstance.Find(f => f.IsItTesting == true).id;
                             });
                             SaveHistory(new TB_AccountHistory
                             {
                                 ActionId = ActionInstance.Find(f => f.Name.Equals("EditTerminal")).id,
                                 ObjectA  = EquipmentInstance.GetFullNumber(equip) + ", " + terminal.Number + ", set to test mode"
                             });
                             ShowNotification("./terminal_list.aspx", EquipmentInstance.GetFullNumber(equip) + ", " + terminal.Number + ", set to test mode");
                         }
                         else
                         {
                             ShowNotification("./terminal_list.aspx", "No equipment bind on this terminal.", false);
                         }
                     }
                 }
             }
             else
             {
                 ShowNotification("./terminal_list.aspx", "Terminal is not exist.", false);
             }
         }
     }
 }
Beispiel #15
0
 /// <summary>
 /// 更新设备状态信息
 /// </summary>
 /// <param name="obj"></param>
 protected void Update(TB_EquipmentStatusName obj)
 {
     StatusInstance.Update(f => f.id == obj.id, act => {
         act.Code           = obj.Code;
         act.Name           = obj.Name;
         act.IsItInventory  = obj.IsItInventory;
         act.IsItOutstorage = obj.IsItOutstorage;
         act.IsItOverhaul   = obj.IsItOverhaul;
         act.IsItWaiting    = obj.IsItWaiting;
         act.IsItRental     = obj.IsItRental;
         act.IsItTesting    = obj.IsItTesting;
         act.IsItVehicle    = obj.IsItVehicle;
     });
 }
Beispiel #16
0
        //attacks
        //spells
        //AI decider

        //target, inventory, attributes, spells, (maybe skills), exhaustion,
        //time of last action / time at which hp recovery will happen, current path,
        // target last known location, player visibility counter for stealth,
        // group

        // Eventually I might need to declare that certain statuses are 'always refresh', which means I track the
        //   EventScheduling and reuse it if it exists (by updating the delay on it). That means tracking, per creature,
        //   a status->scheduling association...then, on add, it would use a new Hemlock feature to check whether it
        //   _would_ be prevented... And then, this state would either need to be serialized, or I'd need to guarantee
        //   that it could be reconstructed (by disallowing any non-refreshing instances of those statuses).
        //   (problem with the always-refresh plan: my priority queue is O(n) for changing priority. Just try the 'event spam' version first.)

        public bool ApplyStatus(Status status, int duration)
        {
            //todo, 'if status is always-refresh, look for existing scheduling'...
            StatusInstance <Creature> inst = StatusTracker.CreateStatusInstance(status);

            if (StatusTracker.AddStatusInstance(inst))
            {
                Q.ScheduleWithRelativeInitiative(new StatusExpirationEvent(this, inst), duration, RelativeInitiativeOrder.BeforeCurrent);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #17
0
        private void ShowCheckoutTypes()
        {
            var state = StatusInstance.FindList(f => f.IsItRental == true || f.IsItOutstorage == true);

            ddlOuttype.Items.Add(new ListItem()
            {
                Value = "", Text = "Out type:"
            });
            foreach (var stat in state)
            {
                ddlOuttype.Items.Add(new ListItem()
                {
                    Value = stat.id.ToString(), Text = stat.Name
                });
            }
        }
Beispiel #18
0
        private void NewStatus()
        {
            var t = StatusInstance.GetObject();

            BuildStatus(t);
            StatusInstance.Add(t);

            // 保存历史记录
            SaveHistory(new TB_AccountHistory
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("AddEquipmentStatus")).id,
                ObjectA  = "[id=" + t.id + "] " + t.Name + ", " + t.Code
            });

            ShowNotification("./equipment_status.aspx", "You have added a new Equipment type: " + t.Name + "(" + t.Code + ").");
        }
        /// <summary>
        /// 显示设备状态列表
        /// </summary>
        private void ShowEquipmentSituations()
        {
            ddlType.Items.Clear();
            ddlType.Items.Add(new ListItem()
            {
                Text = "Select Situation:", Value = ""
            });
            var statuses = StatusInstance.FindList(null).OrderBy(o => o.Name);

            foreach (var status in statuses)
            {
                ddlType.Items.Add(new ListItem()
                {
                    Text = status.Name, Value = status.id.ToString()
                });
            }
        }
Beispiel #20
0
        /// <summary>
        /// 显示设备状态列表
        /// </summary>
        private void ShowEquipmentStatus()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = StatusInstance.FindPageList <TB_EquipmentStatusName>(pageIndex, PageSize, out totalRecords, null, "Name");
            var totalPages   = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"12\">No records, you can change condition and try again, or " +
                       " <a>Add</a> some new one.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            // 系统默认角色无法删除
                            "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" +
                            "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" +
                            "<td><a href=\"./equipment_status.aspx?key=" + id + "\" >" + ("" == obj.Name ? "-" : obj.Name) + "</a></td>" +
                            "<td>" + obj.Code + "</td>" +
                            "<td>" + (obj.IsItInventory == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItOutstorage == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItOverhaul == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItWaiting == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItRental == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItTesting == true ? "Yes" : "-") + "</td>" +
                            "<td>" + (obj.IsItVehicle == true ? "Yes" : "-") + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_status.aspx", divPagging);
            }
        }
Beispiel #21
0
        protected void btRepairComplete_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id        = int.Parse(hidRepairId.Value);
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_overhaul.aspx", "Cannot find the equipment: object is not exist.", false);
                }
                else
                {
                    EquipmentInstance.Update(f => f.id == equipment.id && f.Deleted == false, act =>
                    {
                        act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                    });
                    //RepairOK
                    equipment = EquipmentInstance.Find(f => f.id == equipment.id && f.Deleted == false);

                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    // 先保存维修状态
                    history.Status = equipment.Status;
                    // 保存维修完成信息
                    history.Stocktime = DateTime.Now;
                    // 入库次数不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = equipment.Warehouse;
                    StoreInstance.Add(history);

                    // 保存维修完毕操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("RepairOK")).id,
                        ObjectA  = EquipmentInstance.ToString(equipment)
                    });

                    ShowNotification("./equipment_overhaul.aspx", "Equipment \"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" inspection & repair complete, and re-store in warehouse.");
                }
            }
        }
            [TestCase] public void BasicStatusOperations()
            {
                Assert.Throws <ArgumentNullException>(() => tracker.AddStatusInstance(null));
                Assert.Throws <ArgumentNullException>(() => tracker.RemoveStatusInstance(null));
                StatusInstance <TestObj> s = new StatusInstance <TestObj>((int)TestStatus.E, value: 2);               // (method #1 of creating StatusInstances)

                Assert.AreEqual(0, tracker[TestStatus.E]);
                tracker.AddStatusInstance(s);
                Assert.AreEqual(2, tracker[TestStatus.E]);
                s.Value = 7;
                Assert.AreEqual(7, tracker[TestStatus.E]);
                StatusInstance <TestObj> s2 = tracker.CreateStatusInstance(TestStatus.E, value: 6);                // (method #2 of creating StatusInstances)

                tracker.AddStatusInstance(s2);
                Assert.AreEqual(13, tracker[TestStatus.E]);
                tracker.RemoveStatusInstance(s);
                Assert.AreEqual(6, tracker[TestStatus.E]);
                tracker.Cancel(TestStatus.E);
                Assert.AreEqual(0, tracker[TestStatus.E]);
            }
        /// <summary>
        /// someone played a card against an entity with aggro status.  Is it safe to assume I'm always target here as far as ef is concerned?
        /// Question: someone playing strike with -6 strength; does it trigger aggressive?  probably shouldn't.
        /// </summary>
        internal override void CardWasPlayed(Card card, IndividualEffect playerSet, IndividualEffect enemySet, int intensity, bool statusIsTargeted, bool playerAction)
        {
            if (card.CardType == CardType.Attack && statusIsTargeted)
            {
                if (intensity > 0)
                {
                    //actually this should be a check of the value.
                    if (enemySet.GetInitialDamage() != null)
                    {
                        //bit weird to hack intensity this wasy.
                        var negativeAggressiveStatus = new StatusInstance(new Aggressive(), -1 * intensity);

                        //whoah, this will be applied when the attack is actually resolved.
                        //since here we're
                        enemySet.Status.Add(negativeAggressiveStatus);

                        enemySet.AddBlockStep("Aggrostatus", intensity);
                    }
                }
            }
        }
Beispiel #24
0
    /// <summary>
    /// Inflict the agent with a status effect.
    /// </summary>
    /// <param name="status">The status effect to inflict</param>
    /// <param name="duration">The duration of the status effect</param>
    public void Inflict(Status status, int duration, BattleQueueTime time, string message = "")
    {
        BattleManager manager = GameObject.FindObjectOfType <BattleManager>();

        if (StatusEffects.ContainsKey(status))
        {
            StatusEffects[status]["Duration"] += duration;
        }
        else
        {
            StatusEffects[status] = new StatusInstance(status, duration);

            BattleEvent eventInfo = new BattleEvent(BattleEvent.Type.FirstInflictedWithStatus, manager, time);
            status.OnTrigger(new StatusEvent(eventInfo, status, StatusEffects[status], this));
        }

        if (!message.Equals(""))
        {
            manager.Add(new BattleShowAgentMessage(time, manager, this, message));
        }
    }
Beispiel #25
0
        private void EditStatus()
        {
            var t = StatusInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != t)
            {
                BuildStatus(t);
                Update(t);

                // 保存历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("EditEquipmentStatus")).id,
                    ObjectA  = "[id=" + t.id + "] " + t.Name + ", " + t.Code
                });

                ShowNotification("./equipment_status.aspx", "You changed the equipment status.");
            }
            else
            {
                ShowNotification("./equipment_status.aspx", "Error: paramenter error, cannot edit null object(equipment status).", false);
            }
        }
            [TestCase] public void InstanceOverrides()
            {
                string message      = null;
                string messagePart2 = null;
                int    num          = 0;

                rules[TestStatus.A].Messages.Changed = (obj, status, oldValue, newValue) => {
                    message      = "Status A changed";
                    messagePart2 = "(etc.)";
                };
                rules[TestStatus.A].Effects.Increased = (obj, status, oldValue, newValue) => {
                    num = newValue;
                };
                rules[TestStatus.B].Feeds(TestStatus.A);
                rules.GetOverrideSet(0).Overrides(TestStatus.A).Messages.Changed = (obj, status, oldValue, newValue) => {
                    message = "Status A changed because of status B changing";
                };
                var s = new StatusInstance <TestObj>((int)TestStatus.B, overrideSetIndex: 0);

                tracker.AddStatusInstance(s);
                Assert.AreEqual("Status A changed because of status B changing", message);
                Assert.AreEqual(null, messagePart2);     // The original change message for A did not happen at all
                Assert.AreEqual(1, num);                 // Increase effect was not overridden
            }
Beispiel #27
0
        private void BindEquipment(int terminal, int equipment)
        {
            var ter = TerminalInstance.Find(f => f.id == terminal);

            if (null == ter)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the terminal.", false);
                return;
            }
            else if (ter.HasBound == true)
            {
                ShowNotification("./terminal_list.aspx", "Error: The terminal \"" + ter.Number + "\" has been bound before this time.", false);
                return;
            }
            var equ = EquipmentInstance.Find(f => f.id == equipment && f.Deleted == false);

            if (null == equ)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the equipment.", false);
                return;
            }
            else if (equ.Terminal > 0)
            {
                ShowNotification("./terminal_list.aspx", "Error: The equipment \"" +
                                 EquipmentInstance.GetFullNumber(equ) + "\" has bound an other terminal: \"" + equ.TB_Terminal.Number + "\".", false);
                return;
            }

            // 开始绑定流程
            var storage = StatusInstance.Find(f => f.IsItInventory == true);

            EquipmentInstance.Update(f => f.id == equ.id && f.Deleted == false, act =>
            {
                act.Terminal = ter.id;
                // 更新设备的相应信息为终端的信息
                act.OnlineStyle = ter.OnlineStyle;
                act.OnlineTime  = ter.OnlineTime;
                act.Socket      = ter.Socket;
                // 新品等待入库的,绑定终端之后直接确定为库存状态
                act.Status = storage.id;
            });
            TerminalInstance.Update(f => f.id == ter.id, act => { act.HasBound = true; });

            // 保存入库信息
            var history = StoreInstance.GetObject();

            history.Equipment = equ.id;
            history.Status    = storage.id;
            history.Stocktime = DateTime.Now;
            // 绑定终端时,入库次数不变
            history.StoreTimes = equ.StoreTimes;
            history.Warehouse  = equ.Warehouse;
            StoreInstance.Add(history);

            // 保存操作历史记录
            SaveHistory(new TB_AccountHistory()
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("Bind")).id,
                ObjectA  = "bind equipment " + EquipmentInstance.GetFullNumber(equ) + " and terminal " + ter.Number
            });

            ShowNotification("./terminal_list.aspx", "You have bound \"" + ter.Number + "\" on equipment \"" +
                             EquipmentInstance.GetFullNumber(equ) + "\"");
        }
 public StatusExpirationEvent(Creature creature, StatusInstance <Creature> statusInstance) : base(creature.GameUniverse)
 {
     this.Creature       = creature;
     this.StatusInstance = statusInstance;
 }
Beispiel #29
0
 internal virtual void StatusStartTurn(Entity parent, StatusInstance instance, IndividualEffect statusHolderIe, IndividualEffect otherId)
 {
 }
Beispiel #30
0
 internal override void StatusEndTurn(Entity parent, StatusInstance instance, IndividualEffect statusHolderIe, IndividualEffect otherIe)
 {
     statusHolderIe.Status.Add(new StatusInstance(new Strength(), instance.Intensity));
 }