Esempio n. 1
0
        public Movement(Zone pzs, Zone pzd, Ulist pu, bool piatk)
        {
            if (pzs == null)
            {
                throw new Exception("Starting zone inconsistent(null) !");
            }
            if (pzd == null)
            {
                throw new Exception("Destination zone inconsistent(null) !");
            }
            if (pzd == pzs)
            {
                throw new Exception("Cannot travel there(=) !");
            }
            if (pu == null)
            {
                throw new Exception("No units found in the atack(null) !");
            }
            if (pu.calcNrtotal() == 0)
            {
                throw new Exception("No units found in the atack !");
            }

            zs = pzs;
            zd = pzd;
            u  = pu;
            int t = Math.Abs(zs.X - zd.X) + Math.Abs(zs.Y - zd.Y);

            tm   = new TimeSpan(0, 0, t * 5);
            iatk = piatk;
        }
Esempio n. 2
0
        public void sendAtack(Zone zs,Zone zd, Ulist ul)
        {
            if (zs.owner != this)
                throw new Exception("Cannot send troops from this zone(not owned by this player) !");
            if (ul == null)
                throw new Exception("No army detected(null) !");

            zs.sendAtack(zd, ul);
        }
Esempio n. 3
0
        public void sendSupport(Zone zs, Zone zd, Ulist ul)
        {
            if (zs.owner != this)
            {
                throw new Exception("Cannot send troops from this zone(not owned by this player) !");
            }
            if (ul == null)
            {
                throw new Exception("No army detected(null) !");
            }

            zs.sendSupport(zd, ul);
        }
Esempio n. 4
0
        public Zone(int px, int py, Terrain pt, Player po, Ulist pu, string pnm)
            : this(px, py, pt)
        {
            if (po == null)
                throw new Exception("Owner not found(null) !");
            if (pnm.Length < 1 || pnm.Length > 30)
                throw new Exception("Player name must be between 1 and 30 chars long !");

            o = po;
            u = pu;
            hp = 100;
            nm = pnm;
        }
Esempio n. 5
0
        public Report(DateTime pdt, int pdmg, Zone pzd, Ulist pdbef, Ulist pdaf, Zone pza, Ulist pabef, Ulist paaf)
        {
            if (pdt > DateTime.Now)
                throw new Exception("Invalid record date !");

            dt = pdt;
            dmg = pdmg;
            zd = pzd;
            daf = pdaf;
            dbef = pdbef;
            za = pza;
            abef = pabef;
            aaf = paaf;
        }
Esempio n. 6
0
        public Report(DateTime pdt, int pdmg, Zone pzd, Ulist pdbef, Ulist pdaf, Zone pza, Ulist pabef, Ulist paaf)
        {
            if (pdt > DateTime.Now)
            {
                throw new Exception("Invalid record date !");
            }

            dt   = pdt;
            dmg  = pdmg;
            zd   = pzd;
            daf  = pdaf;
            dbef = pdbef;
            za   = pza;
            abef = pabef;
            aaf  = paaf;
        }
Esempio n. 7
0
        public Movement(Zone pzs, Zone pzd, Ulist pu, bool piatk)
        {
            if (pzs == null)
                throw new Exception("Starting zone inconsistent(null) !");
            if (pzd == null)
                throw new Exception("Destination zone inconsistent(null) !");
            if(pzd==pzs)
                throw new Exception("Cannot travel there(=) !");
            if (pu == null)
                throw new Exception("No units found in the atack(null) !");
            if (pu.calcNrtotal()==0)
                throw new Exception("No units found in the atack !");

            zs = pzs;
            zd = pzd;
            u = pu;
            int t = Math.Abs(zs.X - zd.X) + Math.Abs(zs.Y - zd.Y);
            tm = new TimeSpan(0, 0, t * 5);
            iatk = piatk;
        }
Esempio n. 8
0
 private void sendReturn(Zone pd, Ulist pu)
 {
     if (pu.calcNrtotal() == 0)
         return;
     map.movements.Add(new Movement(this, pd, pu, false));
 }
Esempio n. 9
0
        public void sendSupport(Zone pd, Ulist pu)
        {
            if (pu.bnr < 0 || pu.cnr < 0 || pu.wnr < 0 || pu.pnr < 0 || pu.dnr < 0 || pu.snr < 0)
                throw new Exception("Cannot send less than 0 units !");
            if (pu.calcNrtotal() == 0)
                throw new Exception("Must send at least 1 unit !");
            if (pu.bnr > u.bnr || pu.cnr > u.cnr || pu.wnr > u.wnr || pu.dnr > u.dnr || pu.pnr > u.pnr || pu.snr > u.snr)
                throw new Exception("Cannot send more units than you have !");

            u = new Ulist(u.pnr - pu.pnr, u.wnr - pu.wnr, u.dnr - pu.dnr, u.bnr - pu.bnr, u.cnr - pu.cnr, u.pnr - pu.pnr);
            map.movements.Add(new Movement(this, pd, pu, false));
        }
Esempio n. 10
0
        public void receiveSupport(Movement pm)
        {
            if (pm.zoneD != this)
                throw new Exception("Wrong destination !");

            u = new Ulist(u.pnr + pm.units.pnr, u.wnr + pm.units.wnr, u.dnr + pm.units.dnr, u.bnr + pm.units.bnr, u.cnr + pm.units.cnr, u.pnr + pm.units.pnr);
            map.movements.Remove(pm);
        }