コード例 #1
0
        private int CompareColor(ICardAllDbInfo x, ICardAllDbInfo y, bool colorLessFirst)
        {
            ShardColor xColor      = MultiPartCardManager.Instance.GetColor(x);
            ShardColor yColor      = MultiPartCardManager.Instance.GetColor(y);
            int        xColorCount = ColorCount(xColor);
            int        yColorCount = ColorCount(yColor);

            int?comp;

            //  a) by color order: W, U, B, R, G, MultiColor, Colorless  (For artifact, Colorless  is first)
            if (colorLessFirst)
            {
                comp = CompareEquals(xColor, yColor, ShardColor.Colorless, true);
                if (comp.HasValue)
                {
                    return(comp.Value);
                }
            }



            foreach (ShardColor color in new [] { ShardColor.White, ShardColor.Blue, ShardColor.Black, ShardColor.Red, ShardColor.Green })
            {
                comp = CompareEquals(xColor, yColor, color, true);
                if (comp.HasValue)
                {
                    return(comp.Value);
                }
            }

            if (!colorLessFirst)
            {
                comp = CompareEquals(xColor, yColor, ShardColor.Colorless, false);
                if (comp.HasValue)
                {
                    return(comp.Value);
                }
            }

            //  b) in MultiColor: * by Number of Color
            int c = xColorCount.CompareTo(yColorCount);

            if (c != 0)
            {
                return(c);
            }

            //                    * then Contains W, Contains U, Contains B, Contains R
            foreach (ShardColor color in new[] { ShardColor.White, ShardColor.Blue, ShardColor.Black, ShardColor.Red, ShardColor.Green })
            {
                comp = CompareHasValue(xColor, yColor, color, true);
                if (comp.HasValue && comp.Value != 0)
                {
                    return(comp.Value);
                }
            }

            return(0);
        }
コード例 #2
0
    public static Challenge GetChallenge(Location loc, Player activePlayer)
    {
        ShardColor playerColor = activePlayer.shardAffinity;

        int        rand      = Random.Range(1, 3); // inclusive - exclusive
        ShardColor randColor = (ShardColor)((((((int)playerColor) - 1) + rand) % 3) + 1);

        return(new Challenge(activePlayer.shardAffinity, randColor));
    }
コード例 #3
0
        public ShardColor GetColor(ICardAllDbInfo cai)
        {
            ShardColor color = MagicRules.GetColor(cai.Card.CastingCost);

            if (IsSplitted(cai.Card))
            {
                color |= MagicRules.GetColor(cai.CardPart2.CastingCost);
            }

            return(color);
        }
コード例 #4
0
        private bool CheckColor(CardCollectionInputGraphicViewModel vm)
        {
            if (ColorsSelected.Count == 0)
            {
                return(true);
            }

            ShardColor color           = vm.GetColor();
            bool       wantedColorless = ColorsSelected.Contains(ShardColor.Colorless);
            ShardColor wantedColor     = ColorsSelected.Aggregate(ShardColor.Colorless, (current, newColor) => current | newColor);

            return(Matcher <ShardColor> .HasValue(color, wantedColor) || (wantedColorless && color == ShardColor.Colorless));
        }
コード例 #5
0
        private int ColorCount(ShardColor shardColor)
        {
            int count = 0;

            foreach (ShardColor color in new[] { ShardColor.White, ShardColor.Blue, ShardColor.Black, ShardColor.Red, ShardColor.Green })
            {
                if (Matcher <ShardColor> .HasValue(shardColor, color))
                {
                    count++;
                }
            }
            return(count);
        }
コード例 #6
0
    public static Player RegisterPlayer(ToyWrapper toy, string username, int team, ShardColor aff)
    {
        Player player = new Player(toy);

        toy.customData.SetString("username", username);
        toy.customData.SetBool("registered", true);

        toy.customData.SetInt("affinity", (int)aff);

        toy.customData.SendAsync();

        return(player);
    }
コード例 #7
0
ファイル: Shard.cs プロジェクト: FleurLotus/MPSD
        private Shard(string shardCastingCost, ShardColor color, bool isPhyrexian, bool isHybrid, bool is2Hybrid, bool isHalf)
        {
            ShardCastingCost = shardCastingCost;
            Color            = color;
            IsPhyrexian      = isPhyrexian; // -> CCM = 1
            IsHybrid         = isHybrid;    // -> CCM = 1
            Is2Hybrid        = is2Hybrid;   // -> CCM = 2
            IsHalf           = isHalf;      // -> CCM = 0.5 -> 1

            ConvertedCastingCost = Is2Hybrid ? 2 : 1;

            _toString = string.Format("{0} => {1} CCM={2} {3}{4}{5}{6}", ShardCastingCost, Color, ConvertedCastingCost, IsPhyrexian ? "(IsPhyrexian)" : string.Empty,
                                      IsHybrid ? "(IsHybrid)" : string.Empty, Is2Hybrid ? "(Is2Hybrid)" : string.Empty, IsHalf ? "(IsHalf)" : string.Empty);
        }
コード例 #8
0
    public static ShardColor Add(ShardColor color1, ShardColor color2)
    {
        switch (color1)
        {
        case ShardColor.Red:
        {
            switch (color2)
            {
            case ShardColor.Yellow:
                return(ShardColor.Orange);

            case ShardColor.Blue:
                return(ShardColor.Purple);
            }
        }
        break;

        case ShardColor.Yellow:
        {
            switch (color2)
            {
            case ShardColor.Red:
                return(ShardColor.Orange);

            case ShardColor.Blue:
                return(ShardColor.Green);
            }
        }
        break;

        case ShardColor.Blue:
        {
            switch (color2)
            {
            case ShardColor.Red:
                return(ShardColor.Purple);

            case ShardColor.Yellow:
                return(ShardColor.Green);
            }
        }
        break;
        }

        return(ShardColor.INVALID);
    }
コード例 #9
0
ファイル: SearchViewModel.cs プロジェクト: FleurLotus/MPSD
        private bool CheckColor(ICardAllDbInfo cai)
        {
            if (ColorsSelected.Count == 0)
            {
                return(true);
            }


            ShardColor color = MultiPartCardManager.Instance.GetColor(cai);

            bool wantedColorless = ColorsSelected.Contains(ShardColor.Colorless);

            ShardColor wantedColor = ColorsSelected.Aggregate(ShardColor.Colorless, (current, newColor) => current | newColor);

            if (ColorAggregation == MultiSelectedAggregation.And)
            {
                return(Matcher <ShardColor> .IncludeValue(color, wantedColor));
            }
            //ColorAggregation == MultiSelectedAggregation.Or
            return(Matcher <ShardColor> .HasValue(color, wantedColor) || (wantedColorless && color == ShardColor.Colorless));
        }
コード例 #10
0
    void ChallengeBegin()
    {
        allowNewPlayer = true;
        ChallengeText.gameObject.SetActive(true);
        ScaryBoi.gameObject.SetActive(true);

        ShardColor challengeColor = activeChallenge.getChallengeColor();

        ChallengeText.text = "A challenge appears of " + ShardManager.getName(challengeColor) + " light!";

        switch (challengeColor)
        {
        case ShardColor.Purple: ScaryBoi.sprite = ScaryBoiPurple; break;

        case ShardColor.Green: ScaryBoi.sprite = ScaryBoiGreen; break;

        case ShardColor.Orange: ScaryBoi.sprite = ScaryBoiOrange; break;
        }

        currentStep = Step.Update;
    }
コード例 #11
0
ファイル: MagicRules.cs プロジェクト: FleurLotus/MPSD
        public static DisplayColor GetDisplayColor(string castingCost)
        {
            ShardColor color = GetColor(castingCost);

            if (color == ShardColor.Colorless)
            {
                return(DisplayColor.Colorless);
            }

            if (color == ShardColor.White)
            {
                return(DisplayColor.White);
            }

            if (color == ShardColor.Blue)
            {
                return(DisplayColor.Blue);
            }

            if (color == ShardColor.Black)
            {
                return(DisplayColor.Black);
            }

            if (color == ShardColor.Red)
            {
                return(DisplayColor.Red);
            }

            if (color == ShardColor.Green)
            {
                return(DisplayColor.Green);
            }

            return(DisplayColor.Multicolor);
        }
コード例 #12
0
ファイル: Shard.cs プロジェクト: FleurLotus/MPSD
        private static Shard GetShard(string shardCastingCost)
        {
            if (_shards.TryGetValue(shardCastingCost, out Shard shard))
            {
                return(shard);
            }

            if (int.TryParse(shardCastingCost, out int _))
            {
                //IsGeneric
                shard = new Shard(shardCastingCost, true, false, false, false);
                _shards.Add(shardCastingCost, shard);
                return(shard);
            }

            if (shardCastingCost == Snow)
            {
                //IsSnow
                shard = new Shard(shardCastingCost, false, true, false, false);
                _shards.Add(shardCastingCost, shard);
                return(shard);
            }

            if (shardCastingCost == Colorless)
            {
                //IsColorless
                shard = new Shard(shardCastingCost, false, false, true, false);
                _shards.Add(shardCastingCost, shard);
                return(shard);
            }

            if (Generics.Contains(shardCastingCost))
            {
                //IsXYZ => IsGeneric
                shard = new Shard(shardCastingCost, true, false, false, true);
                _shards.Add(shardCastingCost, shard);
                return(shard);
            }

            string     workingShardCastingCost = shardCastingCost;
            ShardColor color       = ShardColor.Colorless;
            bool       isPhyrexian = false;
            bool       isHybrid    = false;
            bool       is2Hybrid   = false;
            bool       isHalf      = false;

            if (workingShardCastingCost.StartsWith(Half))
            {
                isHalf = true;
                workingShardCastingCost = workingShardCastingCost.Substring(Half.Length);
            }

            if (workingShardCastingCost.EndsWith(Phyrexian))
            {
                isPhyrexian             = true;
                workingShardCastingCost = workingShardCastingCost.Substring(0, workingShardCastingCost.Length - Phyrexian.Length);
            }

            if (workingShardCastingCost.StartsWith(TwoHybrid))
            {
                is2Hybrid = true;
                workingShardCastingCost = workingShardCastingCost.Substring(TwoHybrid.Length);
            }

            if (workingShardCastingCost.Length == 0)
            {
                throw new Exception($"length of workingShardCastingCost is 0 after removing additional info : {shardCastingCost}");
            }

            foreach (char c in workingShardCastingCost)
            {
                isHybrid = color != ShardColor.Colorless;

                switch (c)
                {
                case White:
                    color |= ShardColor.White;
                    break;

                case Blue:
                    color |= ShardColor.Blue;
                    break;

                case Black:
                    color |= ShardColor.Black;
                    break;

                case Red:
                    color |= ShardColor.Red;
                    break;

                case Green:
                    color |= ShardColor.Green;
                    break;

                default:
                    throw new Exception($"Unknown element in shard cast cost {shardCastingCost}: {c}");
                }
            }

            shard = new Shard(shardCastingCost, color, isPhyrexian, isHybrid, is2Hybrid, isHalf);
            _shards.Add(shardCastingCost, shard);
            return(shard);
        }
コード例 #13
0
 public Challenge(ShardColor player, ShardColor support)
 {
     this.playerColor  = player;
     this.supportColor = support;
 }
コード例 #14
0
 public static string getName(ShardColor sc)
 {
     return(ShardNames[(int)sc]);
 }
コード例 #15
0
 public static Color getColor(ShardColor sc)
 {
     return(actualColorValues[(int)sc]);
 }