Exemplo n.º 1
0
        public void Execute()
        {
            try {
                bool       exec = false;
                InvokeMode mode = InvokeMode.im_ItSelf;

                switch (Action)
                {
                case EffectAction.ea_Instant:
                    // dummy
                    break;

                case EffectAction.ea_Persistent:
                    exec = (Duration == 1);
                    mode = InvokeMode.im_FinAction;
                    break;

                case EffectAction.ea_EachTurn:
                    exec = true;
                    break;

                case EffectAction.ea_RandomTurn:
                    exec = AuxUtils.Chance(10);
                    break;

                case EffectAction.ea_LastTurn:
                    exec = (Duration == 1);
                    break;
                }

                if (exec)
                {
                    EffectID eid = (EffectID)CLSID;

                    if (this is MapEffect)
                    {
                        EffectExt ext = ((MapEffect)this).Ext;
                        InvokeEffect(eid, null, Source, mode, EffectAction.ea_Instant, ext);
                    }
                    else
                    {
                        NWCreature creature   = (NWCreature)Owner;
                        int        lid        = (creature.CurrentField).LandID;
                        bool       LocusValid = (eid == EffectID.eid_Relocation) && creature.IsPlayer && creature.Effects.FindEffectByID(EffectID.eid_LocusMastery) != null && lid != GlobalVars.Land_Valhalla && lid != GlobalVars.Land_Vigrid && lid != GlobalVars.Land_Bifrost && lid != GlobalVars.Land_Nidavellir && lid != GlobalVars.Land_Niflheim && lid != GlobalVars.Land_Ocean;
                        if (LocusValid)
                        {
                            EffectExt ext = new EffectExt();
                            ext.ReqParams = new EffectParams(EffectParams.ep_Place);
                            GlobalVars.nwrWin.InitTarget(EffectID.eid_Relocation, null, mode, ext);
                        }
                        else
                        {
                            creature.UseEffect(eid, Source, mode, null);
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("Effect.execute(): " + ex.Message);
            }
        }