public TriggerData(ConvergePlayer player, ConvergeObject subject, ConvergeObject target, int amount)
 {
     this.player  = player;
     this.subject = subject;
     this.target  = target;
     this.amount  = amount;
 }
        void UpdateController()
        {
            ConvergePlayer oldController = controller;

            if (controlEffects.Count == 0)
            {
                controller = owner;
            }
            else
            {
                controller = controlEffects.Last().controller;
            }

            if (controller != oldController)
            {
                if (zone.zoneId == ConvergeZoneId.Attack)
                {
                    MoveZone(controller.defense);
                }
                else
                {
                    MoveZone(controller.GetZone(zone.zoneId));
                }
            }
        }
        public ConvergeObject(ConvergeCardSpec original, ConvergeZone zone)
        {
            this.original  = original;
            this.art       = original.art;
            this.power     = original.power;
            this.toughness = original.toughness;
            this.keywords  = original.keywords;
            GenerateKeywordsText();
            this.owner      = zone.owner;
            this.controller = owner;
            this.originalActivatedAbilities = new List <ConvergeActivatedAbility>();
            foreach (ConvergeActivatedAbilitySpec spec in original.activatedAbilities)
            {
                originalActivatedAbilities.Add(new ConvergeActivatedAbility(spec, this));
            }
            activatedAbilities = originalActivatedAbilities;

            this.originalTriggeredAbilities = new List <ConvergeTriggeredAbility>();
            foreach (ConvergeTriggeredAbilitySpec spec in original.triggeredAbilities)
            {
                originalTriggeredAbilities.Add(new ConvergeTriggeredAbility(spec, this));
            }
            this.triggeredAbilities = originalTriggeredAbilities;
            MoveZone(zone);
        }
예제 #4
0
 public void EndTurn_action()
 {
     activePlayer.SufferWounds();
     UpdateZoneChanges();
     activePlayer.EndMyTurn();
     activePlayer          = activePlayer.opponent;
     endTurnButton.visible = false;
     countdown             = 30;
 }
        public bool CanTarget(ConvergeObject target, ConvergePlayer you)
        {
            if (original.actionTarget == null)
            {
                return(false);
            }

            ConvergeEffectContext context = new ConvergeEffectContext(this, you);

            return(original.actionTarget.Test(target, context));
        }
예제 #6
0
        public void DoAttackEffect(ConvergeObject target, ConvergePlayer you)
        {
            if (!CanTarget(target, you))
            {
                return;
            }

            ConvergeEffectContext context = new ConvergeEffectContext(source, you, this);

            context.target = target;
            attackEffect.Run(context);
        }
예제 #7
0
        public ConvergeZone(JSONTable template, ConvergePlayer owner, ConvergeZoneId zoneId)
        {
            this.owner      = owner;
            this.zoneId     = zoneId;
            this.basePos    = template.getVector2("basePos");
            this.slotOffset = template.getVector2("slotOffset");
            this.inPlay     = template.getBool("inPlay", false);
            this.isHidden   = template.getBool("isHidden", false);
            Vector2 topLeft     = template.getVector2("topLeft");
            Vector2 bottomRight = template.getVector2("bottomRight");

            bounds = new Rectangle(topLeft.ToPoint(), (bottomRight - topLeft).ToPoint());
        }
예제 #8
0
        public void Activate(ConvergePlayer you)
        {
            if (hasTarget)
            {
                return;
            }

            if (you.TryPayCost(manacost) && source.TryPayAltCost(altCost))
            {
                timesUsed++;
                ConvergeEffectContext context = new ConvergeEffectContext(source, you, this);
                effect.Run(context);
            }
        }
예제 #9
0
        public bool CanActivate(ConvergePlayer you)
        {
            if (!isActive || you != source.controller)
            {
                return(false);
            }

            if (!you.CanPayCost(manacost) || !source.CanPayAltCost(spec.altCost))
            {
                return(false);
            }

            return(true);
        }
        public bool CanBePlayed(ConvergePlayer you)
        {
            if (cost != null && !you.CanPayCost(cost))
            {
                return(false);
            }

            if (cardType.HasFlag(ConvergeCardType.Resource) && you.numLandsPlayed >= you.numLandsPlayable)
            {
                return(false);
            }

            return(true);
        }
        public override void Run(ConvergeEffectContext context)
        {
            List <ConvergeObject> newControllerList = newControllerSelector.GetList(context);

            if (newControllerList.Count == 0)
            {
                return;
            }
            ConvergePlayer newController = newControllerList[0].controller;

            foreach (ConvergeObject victim in victims.GetList(context))
            {
                victim.AddEffect(new ConvergeEffect_Control(newController, context.source, duration));
            }
        }
예제 #12
0
        public void ActivateOn(ConvergeObject target, ConvergePlayer you)
        {
            if (!hasTarget)
            {
                return;
            }

            if (!CanTarget(target, you))
            {
                return;
            }

            if (you.TryPayCost(manacost) && source.TryPayAltCost(altCost))
            {
                timesUsed++;
                ConvergeEffectContext context = new ConvergeEffectContext(source, you, this);
                context.target = target;
                effect.Run(context);
            }
        }
        public void PlayOn(ConvergeObject target, ConvergePlayer you)
        {
            if (zone.zoneId == ConvergeZoneId.Hand &&
                (cardType.HasFlag(ConvergeCardType.Action) || cardType.HasFlag(ConvergeCardType.Augment)) &&
                CanTarget(target, you)
                )
            {
                if (you.TryPayCost(cost))
                {
                    if (TriggerSystem.HasTriggers(ConvergeTriggerType.PlayCard))
                    {
                        TriggerSystem.CheckTriggers(ConvergeTriggerType.PlayCard, new TriggerData(you, this, target, 0));
                    }

                    ConvergeEffectContext context = new ConvergeEffectContext(this, you);
                    context.target = target;
                    original.actionEffect.Run(context);
                    MoveZone(owner.discardPile);
                }
            }
        }
        public void BeginAnyTurn(ConvergePlayer activePlayer)
        {
            if (controlEffects.TickTurn())
            {
                UpdateController();
            }

            if (upgradeEffects.TickTurn())
            {
                UpdateUpgrades();
            }

            if (extraActivatedEffects.TickTurn())
            {
                UpdateActivated();
            }

            if (extraTriggeredEffects.TickTurn())
            {
                UpdateTriggered();
            }
        }
예제 #15
0
        public bool CanTarget(ConvergeObject target, ConvergePlayer you)
        {
            ConvergeEffectContext context = new ConvergeEffectContext(source, you, this);

            return(spec.target.Test(target, context));
        }
 public ConvergeEffectContext(ConvergeObject source, ConvergePlayer you, ConvergeActivatedAbility ability)
 {
     this.source  = source;
     this.you     = you;
     this.ability = ability;
 }
        public override void Draw(SpriteBatch spriteBatch, Vector2 pos)
        {
            if (!isVisible)
            {
                return;
            }

            ConvergePlayer controller = represented.controller;

            // attack beam
            if (represented.zone.zoneId == ConvergeZoneId.Attack &&
                !represented.dying &&
                (
                    (!represented.tapped && represented.effectivePower > 0 && ((represented.controller == Game1.activePlayer) == (Game1.countdown > 0))) ||
                    represented.attackVictim != null
                )
                )
            {
                Rectangle targetFrame;

                if (represented.attackVictim != null)
                {
                    targetFrame = represented.attackVictim.ui.gfxFrame;
                }
                else
                {
                    targetFrame = represented.controller.opponent.homeBase.ui.gfxFrame;
                }
                int thickness = Game1.countdown == 0? 16: 16 + (120 - Game1.countdown) / 6;
                spriteBatch.DrawBeam(Game1.attackBeam, new Vector2(gfxFrame.Center.X, gfxFrame.Bottom), new Vector2(targetFrame.Center.X, targetFrame.Bottom - 5), thickness, Color.White);
            }

            Texture2D art     = represented.art;
            Color     artTint = Color.White;

            if (represented.zone.zoneId == ConvergeZoneId.DiscardPile)
            {
                artTint = Color.Black;
            }
            else if (represented.tapped)
            {
                artTint = TappedTint;
            }

            spriteBatch.Draw(
                represented.art,
                new Rectangle(gfxFrame.Center.X - art.Width / 2, gfxFrame.Bottom - art.Height, art.Width, art.Height),
                null,
                artTint,
                0.0f,
                Vector2.Zero,
                controller.faceLeft ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                0.0f
                );

            if (represented.tapped)
            {
                spriteBatch.Draw(Game1.tappedicon, new Vector2(gfxFrame.Right - 16, gfxFrame.Top), Color.White);
            }

            if (represented.zone.zoneId == ConvergeZoneId.DiscardPile)
            {
                return;
            }

            if (represented.cardType.HasFlag(ConvergeCardType.Unit))
            {
                if (represented.power > 0)
                {
                    spriteBatch.Draw(Game1.powerbg, new Rectangle(gfxFrame.Left + 8, gfxFrame.Bottom, 16, 16), Color.White);
                    spriteBatch.DrawString(Game1.font, "" + represented.effectivePower, new Vector2(gfxFrame.Left + 16, gfxFrame.Bottom), TextAlignment.CENTER, represented.powerUsed > 0 ? Color.Red : Color.Yellow);
                }

                Rectangle toughnessRect    = new Rectangle(gfxFrame.Right - 24, gfxFrame.Bottom, 16, 16);
                Vector2   toughnessTextPos = new Vector2(gfxFrame.Right - 16, gfxFrame.Bottom);
                if (represented.destroyed)
                {
                    spriteBatch.Draw(Game1.woundbg, toughnessRect, Color.White);
                    spriteBatch.DrawString(Game1.font, "X", toughnessTextPos, TextAlignment.CENTER, Color.Red);
                }
                else if (represented.effectiveToughness <= 0)
                {
                    spriteBatch.Draw(Game1.woundbg, toughnessRect, Color.White);
                    spriteBatch.DrawString(Game1.font, "" + represented.effectiveToughness, toughnessTextPos, TextAlignment.CENTER, Color.Red);
                }
                else
                {
                    spriteBatch.Draw(Game1.shieldbg, new Rectangle(gfxFrame.Right - 24, gfxFrame.Bottom, 16, 16), Color.White);
                    spriteBatch.DrawString(Game1.font, "" + represented.effectiveToughness, toughnessTextPos, TextAlignment.CENTER, represented.damage > 0 ? Color.Red : Color.White);
                }
            }

            if (represented.cardType.HasFlag(ConvergeCardType.Home))
            {
                spriteBatch.DrawString(Game1.font, "" + controller.life, new Vector2(gfxFrame.Center.X, gfxFrame.Top + 20), TextAlignment.CENTER, Color.Black);

                Vector2 resourcePos;
                if (controller.faceLeft)
                {
                    resourcePos = new Vector2(gfxFrame.Left, gfxFrame.Bottom);
                }
                else
                {
                    resourcePos = new Vector2(gfxFrame.Center.X, gfxFrame.Bottom);
                }
                controller.resources.DrawResources(spriteBatch, controller.showResources, resourcePos);
            }

            bool  drawHighlight  = isMouseOver;
            Color highlightColor = Color.White;

            if (represented.zone.zoneId == ConvergeZoneId.Hand)
            {
                if (represented.CanBePlayed(Game1.activePlayer))
                {
                    drawHighlight = true;
                    if (isBadDrag)
                    {
                        highlightColor = Color.Red;
                    }
                    else if (isMouseOver)
                    {
                        highlightColor = Color.Yellow;
                    }
                    else
                    {
                        highlightColor = Color.Orange;
                    }
                }

/*                if (isMouseOver && represented.cost != null)
 *              {
 *                  represented.cost.DrawCost(spriteBatch, new Vector2(gfxFrame.Left, gfxFrame.Top));
 *              }*/
            }
            else if (drawHighlight && !controller.isActivePlayer)
            {
                highlightColor = Color.Red;
            }

            if (drawHighlight)
            {
                spriteBatch.Draw(Game1.mouseOverGlow, gfxFrame, highlightColor);
            }

            foreach (ConvergeUIAbility abilityUI in abilityUIs)
            {
                abilityUI.Draw(spriteBatch);
            }
        }
 public ConvergeEffect_Control(ConvergePlayer controller, ConvergeObject source, ConvergeDuration duration) : base(source, duration)
 {
     this.controller = controller;
 }
예제 #19
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            data = new JSONTable("Content/data.json");

            mouseOverGlow = new RichImage(data.getJSON("mouseOverGlow"), Content);
            cardFrame     = new RichImage(data.getJSON("cardFrame"), Content);
            whiteFrame    = new RichImage(data.getJSON("whiteFrame"), Content);
            blueFrame     = new RichImage(data.getJSON("blueFrame"), Content);
            blackFrame    = new RichImage(data.getJSON("blackFrame"), Content);
            redFrame      = new RichImage(data.getJSON("redFrame"), Content);
            greenFrame    = new RichImage(data.getJSON("greenFrame"), Content);
            goldFrame     = new RichImage(data.getJSON("goldFrame"), Content);

            font             = Content.Load <SpriteFont>("Arial");
            shieldbg         = Content.Load <Texture2D>("shieldbg");
            powerbg          = Content.Load <Texture2D>("powerbg");
            woundbg          = Content.Load <Texture2D>("woundbg");
            tappedicon       = Content.Load <Texture2D>("tapped");
            abilityHighlight = Content.Load <Texture2D>("abilityHighlight");
            targetArrow      = Content.Load <Texture2D>("targetArrow");
            targetBeam       = Content.Load <Texture2D>("targetBeam");
            badTargetArrow   = Content.Load <Texture2D>("badTargetArrow");
            badTargetBeam    = Content.Load <Texture2D>("badTargetBeam");
            attackBeam       = Content.Load <Texture2D>("attackBeam");

            resourceTextures = new Texture2D[]
            {
                Content.Load <Texture2D>("total_resources"),
                Content.Load <Texture2D>("white_hats"),
                Content.Load <Texture2D>("blue_science"),
                Content.Load <Texture2D>("black_hats"),
                Content.Load <Texture2D>("red_munitions"),
                Content.Load <Texture2D>("green_seeds"),
            };

            ui = new UIContainer();

            self              = new ConvergePlayer(data.getJSON("self"), Content);
            opponent          = new ConvergePlayer(data.getJSON("opponent"), Content);
            self.opponent     = opponent;
            opponent.opponent = self;

            ui.Add(new ConvergeUIObject(self.homeBase));
            ui.Add(new ConvergeUIObject(opponent.homeBase));

            UIButtonStyle defaultStyle = UIButton.GetDefaultStyle(Content);

            endTurnButton = new UIButton("End Turn", new Rectangle(600, 400, 80, 40), defaultStyle, EndTurn_action, uiActions);
            ui.Add(endTurnButton);

            UIButton newHandButton = new UIButton("Cheat:New Hand", new Rectangle(600, 300, 80, 40), defaultStyle, NewHand_action, uiActions);

            ui.Add(newHandButton);

            JSONTable allCardsTemplate = data.getJSON("cards");

            foreach (string cardName in allCardsTemplate.Keys)
            {
                ConvergeCardSpec newSpec = new ConvergeCardSpec();
                ConvergeCardSpec.allCards.Add(cardName, newSpec);

                newSpec.Init(allCardsTemplate.getJSON(cardName), Content);
            }

            foreach (string cardName in data.getArray("mydeck").asStrings())
            {
                //ConvergeObject handCard =
                new ConvergeObject(ConvergeCardSpec.allCards[cardName], self.laboratory);
                //ui.Add(new ConvergeUIObject(handCard));
            }

            foreach (string cardName in data.getArray("oppdeck").asStrings())
            {
                //ConvergeObject handCard =
                new ConvergeObject(ConvergeCardSpec.allCards[cardName], opponent.laboratory);
                //ui.Add(new ConvergeUIObject(handCard));
            }


            UpdateZoneChanges();

            self.BeginGame();
            opponent.BeginGame();

            activePlayer = self;
            self.BeginMyTurn();
            opponent.numLandsPlayed = 1; // can't play a land in your first response phase
        }
        public void Play(ConvergePlayer you)
        {
            if (zone.zoneId == ConvergeZoneId.Hand)
            {
                if (this.cardType.HasFlag(ConvergeCardType.Resource))
                {
                    if (you.numLandsPlayed < you.numLandsPlayable)
                    {
                        you.numLandsPlayed++;
                    }
                    else
                    {
                        return;
                    }
                }
                else if (original.actionTarget != null)
                {
                    // this spell needs a target
                    return;
                }

                if (TriggerSystem.HasTriggers(ConvergeTriggerType.PlayCard))
                {
                    TriggerSystem.CheckTriggers(ConvergeTriggerType.PlayCard, new TriggerData(you, this, null, 0));
                }

                if (you.TryPayCost(cost))
                {
                    if (this.cardType.HasFlag(ConvergeCardType.Unit))
                    {
                        MoveZone(you.defense);
                        if (!this.keywords.HasFlag(ConvergeKeyword.Haste))
                        {
                            tapped = true;
                        }
                    }
                    else if (this.cardType.HasFlag(ConvergeCardType.Action))
                    {
                        ConvergeEffectContext context = new ConvergeEffectContext(this, you);
                        original.actionEffect.Run(context);
                        MoveZone(owner.discardPile);
                    }
                    else if (this.cardType.HasFlag(ConvergeCardType.Resource) && this.activatedAbilities.Count == 0)
                    {
                        MoveZone(you.resourceZone);
                    }
                    else
                    {
                        MoveZone(you.home);
                    }
                }
            }
            else if (zone.zoneId == ConvergeZoneId.Attack)
            {
                WithdrawAttack();
            }
            else if (zone.zoneId == ConvergeZoneId.Defense)
            {
                EnterAttack();
            }
        }
 public ConvergeEffectContext(ConvergeObject source, ConvergePlayer you)
 {
     this.source = source;
     this.you    = you;
 }