Exemplo n.º 1
0
        private static void GenerateSkillCardDeck(SkillCardColor color)
        {
            var baseDocument = new XmlDocument();

            baseDocument.Load(@"..\..\BaseJsonGeneratorOutput\Core.xml");
            var    cardsFromBox = new List <SkillCard>();
            string deckName     = null;

            switch (color)
            {
            case SkillCardColor.Engineering:
                deckName = "ENGdeck";
                break;

            case SkillCardColor.Leadership:
                deckName = "LEAdeck";
                break;

            case SkillCardColor.Piloting:
                deckName = "PILdeck";
                break;

            case SkillCardColor.Politics:
                deckName = "POLdeck";
                break;

            case SkillCardColor.Tactics:
                deckName = "TACdeck";
                break;
            }
            var jo    = JObject.Parse(JsonConvert.SerializeXmlNode(baseDocument));
            var token = jo["ROOT"][deckName];

            cardsFromBox.AddRange(
                token["card"].Children().Select(
                    element => element.Value <string>("text"))
                .Select(
                    headerText => new SkillCard
            {
                Heading   = headerText,
                CardColor = color,
                CardPower =
                    headerText[headerText.IndexOfAny(new[] { '0', '1', '2', '3', '4', '5' })]
                    .ToString(CultureInfo.InvariantCulture).ParseAs <int>()
            }
                    )
                );

            var jsonSettings = new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore, Converters = new List <JsonConverter> {
                    new Newtonsoft.Json.Converters.StringEnumConverter()
                }
            };
            var json = JsonConvert.SerializeObject(cardsFromBox, Newtonsoft.Json.Formatting.Indented, jsonSettings);

            using (var sr = new StreamWriter(@"..\..\BaseJsonGeneratorOutput\GeneratedJson\Decks\" + color + "Deck.json"))
            {
                sr.Write(json);
            }
        }
Exemplo n.º 2
0
        private void InitDeck(SkillCardColor color)
        {
            var cardsFromBox = new List <SkillCard>();

            //TODO: Import the cards via JSON/XML reader - the goddamn NuGet packages aren't working right now.  Fill up the cardsFromBox object.

            Deck      = cardsFromBox;
            Deck      = Shuffle(Deck);
            DeckColor = color;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the deck.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <param name="fileLocation">The file location.</param>
        private void InitDeck(SkillCardColor color, string fileLocation)
        {
            var cardsFromBox = new List <SkillCard>();

            if (fileLocation != null)
            {
                using (var sr = new StreamReader(fileLocation))
                {
                    var jsonText = sr.ReadToEnd();
                    cardsFromBox = JsonConvert.DeserializeObject <List <SkillCard> >(jsonText);
                }
            }

            Deck      = cardsFromBox;
            Deck      = Shuffle(Deck);
            DeckColor = color;
            Discarded = new List <SkillCard>();
        }
Exemplo n.º 4
0
        public IEnumerable <SkillCard> DrawSkillCards(SkillCardColor color, int count, Player player = null)
        {
            List <SkillCard> ret;

            switch (color)
            {
            case SkillCardColor.Engineering:
                ret = CurrentGameState.EngineeringDeck.DrawMany(count).ToList();
                break;

            case SkillCardColor.Leadership:
                ret = CurrentGameState.LeadershipDeck.DrawMany(count).ToList();
                break;

            case SkillCardColor.Piloting:
                ret = CurrentGameState.PilotingDeck.DrawMany(count).ToList();
                break;

            case SkillCardColor.Politics:
                ret = CurrentGameState.PoliticsDeck.DrawMany(count).ToList();
                break;

            case SkillCardColor.Tactics:
                ret = CurrentGameState.TacticsDeck.DrawMany(count).ToList();
                break;

            case SkillCardColor.Treachery:
                ret = CurrentGameState.TreacheryDeck.DrawMany(count).ToList();
                break;

            default:
                return(new List <SkillCard>());
            }

            if (player != null)
            {
                player.TakeCard(ret);
            }
            return(ret);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Returns the maximum number of cards the character can draw of this color.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <returns></returns>
 public int ColorMax(SkillCardColor color)
 {
     return DefaultDrawColors.Select(draw => draw.Count(x => x == color)).Concat(new[] {0}).Max();
 }
Exemplo n.º 6
0
        private static void GenerateSkillCardDeck(SkillCardColor color)
        {
            var baseDocument = new XmlDocument();
            baseDocument.Load(@"..\..\PegasusJsonGeneratorOutput\Pegasus.xml");
            var cardsFromBox = new List<SkillCard>();
            string deckName = null;
            switch (color)
            {
                case SkillCardColor.Engineering:
                    deckName = "ENGdeck";
                    break;
                case SkillCardColor.Leadership:
                    deckName = "LEAdeck";
                    break;
                case SkillCardColor.Piloting:
                    deckName = "PILdeck";
                    break;
                case SkillCardColor.Politics:
                    deckName = "POLdeck";
                    break;
                case SkillCardColor.Tactics:
                    deckName = "TACdeck";
                    break;
                case SkillCardColor.Treachery:
                    deckName = "TREdeck";
                    break;
            }
            var jo = JObject.Parse(JsonConvert.SerializeXmlNode(baseDocument));
            var token = jo["ROOT"][deckName];
            cardsFromBox.AddRange(
                token["card"].Children().Select(
                    element => element.Value<string>("text"))
                             .Select(
                                 headerText => new SkillCard
                                 {
                                     Heading = headerText,
                                     CardColor = color,
                                     CardPower =
                                         headerText[headerText.IndexOfAny(new[] { '0', '1', '2', '3', '4', '5', '6' })]
                                               .ToString(CultureInfo.InvariantCulture).ParseAs<int>()
                                 }
                    )
                );

            var jsonSettings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore, Converters = new List<JsonConverter> { new Newtonsoft.Json.Converters.StringEnumConverter() } };
            var json = JsonConvert.SerializeObject(cardsFromBox, Newtonsoft.Json.Formatting.Indented, jsonSettings);
            using (var sr = new StreamWriter(@"..\..\PegasusJsonGeneratorOutput\GeneratedJson\Decks\"+color+"Deck.json"))
            {
                sr.Write(json);
            }
        }
Exemplo n.º 7
0
 public SkillCard DrawSkillCard(SkillCardColor color, Player player = null)
 {
     return(DrawSkillCards(color, 1, player).FirstOrDefault());
 }
Exemplo n.º 8
0
        public IEnumerable<SkillCard> DrawSkillCards(SkillCardColor color, int count, Player player = null)
        {
            List<SkillCard> ret;
            switch (color)
            {
                case SkillCardColor.Engineering:
                    ret = CurrentGameState.EngineeringDeck.DrawMany(count).ToList();
                    break;
                case SkillCardColor.Leadership:
                    ret = CurrentGameState.LeadershipDeck.DrawMany(count).ToList();
                    break;
                case SkillCardColor.Piloting:
                    ret = CurrentGameState.PilotingDeck.DrawMany(count).ToList();
                    break;
                case SkillCardColor.Politics:
                    ret = CurrentGameState.PoliticsDeck.DrawMany(count).ToList();
                    break;
                case SkillCardColor.Tactics:
                    ret = CurrentGameState.TacticsDeck.DrawMany(count).ToList();
                    break;
                case SkillCardColor.Treachery:
                    ret = CurrentGameState.TreacheryDeck.DrawMany(count).ToList();
                    break;
                default:
                    return new List<SkillCard>();
            }

            if (player != null)
                player.TakeCard(ret);
            return ret;
        }
Exemplo n.º 9
0
 public SkillCard DrawSkillCard(SkillCardColor color, Player player = null)
 {
     return DrawSkillCards(color, 1, player).FirstOrDefault();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkillCardDeck"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="color">The color.</param>
 /// <param name="fileLocation">The file location.</param>
 public SkillCardDeck(ILog logger, SkillCardColor color, string fileLocation) : base(logger)
 {
     InitDeck(color, fileLocation);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns the maximum number of cards the character can draw of this color.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <returns></returns>
 public int ColorMax(SkillCardColor color)
 {
     return(DefaultDrawColors.Select(draw => draw.Count(x => x == color)).Concat(new[] { 0 }).Max());
 }
Exemplo n.º 12
0
 public SkillCardDeck(ILog logger, SkillCardColor color) : base(logger)
 {
     InitDeck(color);
 }