Esempio n. 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            City = CityLoyaltySystem.GetCityInstance((City)reader.ReadInt());

            if (City != null)
            {
                City.Stone = this;
            }

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                BallotBox box = reader.ReadItem() as BallotBox;

                if (box != null)
                {
                    if (Boxes == null)
                    {
                        Boxes = new List <BallotBox>();
                    }

                    Boxes.Add(box);
                }
            }
        }
Esempio n. 2
0
        public override void AddGumpLayout()
        {
            if (City == null || City.Stone == null || City.Stone.Boxes == null)
            {
                return;
            }

            AddBackground(0, 0, 250, (City.Stone.Boxes.Count * 25) + 90, 5054);
            AddHtml(0, 15, 250, 20, String.Format("<center>Inventory - {0}</center>", City.Definition.Name), false, false); // Inventory

            AddLabel(10, 40, 0, "Location");
            AddLabel(150, 40, 0, "View");
            AddLabel(200, 40, 0, "Remove");

            City.Stone.Boxes.ForEach(b =>
            {
                if (b.Deleted)
                {
                    City.Stone.Boxes.Remove(b);
                }
            });

            for (int i = 0; i < City.Stone.Boxes.Count; i++)
            {
                BallotBox box = City.Stone.Boxes[i];

                AddLabel(10, 70 + (i * 25), 0, box == null || box.Deleted ? "Deleted" : box.Location.ToString());
                AddButton(150, 70 + (i * 25), 4011, 4013, i + 100, GumpButtonType.Reply, 0);
                AddButton(200, 70 + (i * 25), 4017, 4019, i + 200, GumpButtonType.Reply, 0);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BallotBox ballotBox = db.BallotBoxes.Find(id);

            db.BallotBoxes.Remove(ballotBox);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "BallotBoxId,BallotBoxNumber,NeighbourhoodId,VoterCount")] BallotBox ballotBox)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ballotBox).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NeighbourhoodId = new SelectList(db.Neighbourhoods, "NeighbourhoodId", "NeighbourhoodName", ballotBox.NeighbourhoodId);
     return(PartialView(ballotBox));
 }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "BallotBoxId,BallotBoxNumber,NeighbourhoodId,VoterCount")] BallotBox ballotBox)
        {
            if (ModelState.IsValid)
            {
                db.BallotBoxes.Add(ballotBox);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NeighbourhoodId = new SelectList(db.Neighbourhoods, "NeighbourhoodId", "NeighbourhoodName", ballotBox.NeighbourhoodId);
            return(View(ballotBox));
        }
        // GET: BallotBoxes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BallotBox ballotBox = db.BallotBoxes.Find(id);

            if (ballotBox == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(ballotBox));
        }
        // GET: BallotBoxes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BallotBox ballotBox = db.BallotBoxes.Find(id);

            if (ballotBox == null)
            {
                return(HttpNotFound());
            }
            ViewBag.NeighbourhoodId = new SelectList(db.Neighbourhoods, "NeighbourhoodId", "NeighbourhoodName", ballotBox.NeighbourhoodId);
            return(PartialView(ballotBox));
        }
Esempio n. 8
0
        public override void OnResponse(RelayInfo info)
        {
            Mobile m = User;

            if (info.ButtonID == 0)
            {
                return;
            }

            int id;

            if (info.ButtonID < 200)
            {
                id = info.ButtonID - 100;

                if (id >= 0 && id < City.Stone.Boxes.Count)
                {
                    BallotBox box = City.Stone.Boxes[id];
                    box.SendGumpTo(m);
                }
            }
            else
            {
                id = info.ButtonID - 200;

                if (id >= 0 && id < City.Stone.Boxes.Count)
                {
                    BallotBox box = City.Stone.Boxes[id];

                    m.SendGump(new WarningGump(1111873, 30720, "This will permanently delete the ballot box. Proceed?", 32512, 300, 200, (mob, ok, obj) =>
                    {
                        if (ok)
                        {
                            box.Delete();
                            City.Stone.Boxes.Remove(box);

                            m.SendMessage("Ballot box deleted.");
                        }

                        m.CloseGump(typeof(OpenInventoryGump));
                        BaseGump.SendGump(new OpenInventoryGump(User, City));
                    }, box, true));
                }
            }
        }
Esempio n. 9
0
        public bool CheckLocation(Mobile m, BallotBox box, IPoint3D p)
        {
            Region r = Region.Find(new Point3D(p), Map);

            if (!r.IsPartOf(City.Definition.Region))
            {
                m.SendMessage("You can only place a ballot box within the {0} city limits!", City.Definition.Name);
                return(false);
            }

            if (!box.DropToWorld(new Point3D(p), Map))
            {
                m.SendMessage("You cannot place a ballot box there!");
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
 private void Start()
 {
     m_ballotBox = new BallotBox();
 }
Esempio n. 11
0
        public override void GetContextMenuEntries(Mobile from, List <ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);

            if (!CityLoyaltySystem.Enabled || City == null)
            {
                return;
            }

            if (!City.IsCitizen(from))
            {
                if (City.Herald != null)
                {
                    City.Herald.SayTo(from, 1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
                }
                else
                {
                    from.SendLocalizedMessage(1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
                }
                return;
            }

            list.Add(new SimpleContextMenuEntry(from, 1154018, m => // Grant Citizen Title
            {
                if (City.IsGovernor(m))
                {
                    m.SendLocalizedMessage(1154027);     // Which Citizen do you wish to bestow a title?
                    m.BeginTarget(10, false, TargetFlags.None, (mob, targeted) =>
                    {
                        PlayerMobile pm = targeted as PlayerMobile;

                        if (pm != null)
                        {
                            if (City.IsCitizen(pm))
                            {
                                BaseGump.SendGump(new PlayerTitleGump(mob as PlayerMobile, pm, City));
                            }
                            else
                            {
                                mob.SendLocalizedMessage(1154029);         // You may only bestow a title on citizens of this city!
                            }
                        }
                        else
                        {
                            mob.SendLocalizedMessage(1154028);         // You can only bestow a title on a player!
                        }
                    });
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154031, m => // Open Trade Deal
            {
                if (City.IsGovernor(m))
                {
                    BaseGump.SendGump(new ChooseTradeDealGump(m as PlayerMobile, City));
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154277, m => // Open Inventory WTF is this?
            {
                if (m is PlayerMobile && City.IsGovernor(m))
                {
                    BaseGump.SendGump(new OpenInventoryGump((PlayerMobile)m, City));
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154278, m => // Place Ballot Box
            {
                if (City.IsGovernor(m))
                {
                    if (Boxes != null && Boxes.Count >= CityLoyaltySystem.MaxBallotBoxes)
                    {
                        m.SendMessage("You have reached the maximum amount of ballot boxes in your city.");
                        return;
                    }

                    m.SendMessage("Where would you like to place a ballot box?");
                    m.BeginTarget(3, true, TargetFlags.None, (mob, targeted) =>
                    {
                        if (targeted is IPoint3D)
                        {
                            IPoint3D p = targeted as IPoint3D;
                            Server.Spells.SpellHelper.GetSurfaceTop(ref p);
                            BallotBox box = new BallotBox();

                            if (CheckLocation(m, box, p))
                            {
                                box.Owner   = m;
                                box.Movable = false;

                                if (Boxes == null)
                                {
                                    Boxes = new List <BallotBox>();
                                }

                                Boxes.Add(box);
                                box.MoveToWorld(new Point3D(p), Map);

                                m.SendMessage("{0} of {1} ballot boxes placed.", Boxes.Count.ToString(), CityLoyaltySystem.MaxBallotBoxes.ToString());
                            }
                            else
                            {
                                box.Delete();
                            }
                        }
                    });
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154060, m => // Utilize Trade Deal
            {
                City.TryUtilizeTradeDeal(from);
            }, enabled: City.ActiveTradeDeal != TradeDeal.None));

            CityLoyaltyEntry entry = City.GetPlayerEntry <CityLoyaltyEntry>(from);

            list.Add(new SimpleContextMenuEntry(from, 1154019, m => // Remove City Title
            {
                if (entry != null && entry.CustomTitle != null)
                {
                    entry.CustomTitle = null;

                    if (m is PlayerMobile)
                    {
                        ((PlayerMobile)m).RemoveRewardTitle(1154017, true);
                    }

                    m.SendMessage("City Title removed.");
                }
            }, enabled: entry != null && entry.CustomTitle != null));

            list.Add(new SimpleContextMenuEntry(from, 1154068, m => // Accept Office
            {
                if (m is PlayerMobile && m == City.GovernorElect && City.Governor == null)
                {
                    BaseGump.SendGump(new AcceptOfficeGump(m as PlayerMobile, City));
                }
            }, enabled: City.GovernorElect == from && City.Governor == null && City.GetLoyaltyRating(from) >= LoyaltyRating.Unknown));
        }
Esempio n. 12
0
 public BallotBoxTest()
 {
     box = new BallotBox();
 }