Esempio n. 1
0
        /** Add an option to the optionlist with the given values. */
        public static void Add(OptionList optionList, string name, int value, string strValue)
        {
            #if DEBUG
            Console.WriteLine("Option.Add");
            #endif
            if (optionList.list == null)
                optionList.list = new ArrayList();
            if (optionList.datalist == null)
                optionList.datalist = new Dictionary<string, OptionStruct>();

            if (optionList.datalist.ContainsKey(name))
            {
                OptionStruct option = optionList.datalist[name];
                if (Variables.debug_level > 0)
                    Debug.PrintMessage("Option {0} already in optionlist\n", name);
                option.value = value;
                option.stringValue = strValue;
            }
            else
            {
                OptionStruct newOption = new OptionStruct();
                newOption.name = name;
                newOption.value = value;
                newOption.stringValue = strValue;
                optionList.list.Add(newOption);

                optionList.datalist.Clear();
                foreach (OptionStruct option in optionList.list)
                {
                    if (!optionList.datalist.ContainsKey(option.name))
                        optionList.datalist.Add(option.name, option);
                }
            }
        }
Esempio n. 2
0
        public static int OptionInt(string name, OptionList optionList)
        {
            #if DEBUG
            Console.WriteLine("OptionInt");
            #endif
            if (optionList.datalist.ContainsKey(name))
                return optionList.datalist[name].value;

            Program.ExitProgram(ExitCodes.EXIT_OPTION_NOT_FOUND, "OptionInt: option named {0} not found\nMaybe you should delete the .bygfoot directory from your home dir", name);
            return -1;
        }
Esempio n. 3
0
 public static void OptionInt(string name, OptionList optionList, int value)
 {
     #if DEBUG
     Console.WriteLine("OptionInt.Set");
     #endif
     Add (optionList, name, value, string.Empty);
 }
Esempio n. 4
0
        /** Load a file containing name - value pairs into
         * the specified array. */
        public static void LoadOptFile(string filename, ref OptionList optionList, bool sort)
        {
            #if DEBUG
            Console.WriteLine("FileHelper.LoadOptFile");
            #endif
            optionList = new OptionList();
            string path = FindSupportFile(filename, false);
            string[] lines = File.ReadAllLines(path);
            foreach (string line in lines)
            {
                string optName = null, optValue = null;
                if (ParseOptLine(line, ref optName, ref optValue))
                {
                    OptionStruct option = new OptionStruct();
                    option.name = optName;
                    if (optName.StartsWith("string_"))
                    {
                        option.stringValue = optValue;
                        option.value = -1;
                    }
                    else
                    {
                        option.stringValue = null;
                        option.value = Int32.Parse(optValue);
                    }
                    optionList.list.Add(option);

                    if ((optName.EndsWith("_unix") && Variables.os_is_unix) ||
                        (optName.EndsWith("_win32") && !Variables.os_is_unix))
                    {
                        option.name = optName.Remove(optName.IndexOf(Variables.os_is_unix ? "_unix" : "_win32"));
                        optionList.list.Add(option);
                    }
                }
            }

            if (sort)
            {
                OptionCompare comparer = new OptionCompare();
                optionList.list.Sort(comparer);
            }

            foreach (OptionStruct option in optionList.list)
            {
                if (!optionList.datalist.ContainsKey(option.name))
                    optionList.datalist.Add(option.name, option);
            }
        }
Esempio n. 5
0
        public User()
        {
            #if DEBUG
            Console.WriteLine("User.New");
            #endif
            Name = "NONAME";
            Team = null;
            TeamId = -1;

            // TODO
            //live_game_reset(&new.live_game, NULL, FALSE);

            Events = new List<Event>();
            History = new List<UserHistory>();
            Options = new OptionList ();
            Options.list = null;
            Options.datalist = null;

            Sponsor = new UserSponsor();

            // TODO
            //new.youth_academy.players = g_array_new(FALSE, FALSE, sizeof(Player));
            //new.youth_academy.pos_pref = PLAYER_POS_ANY;
            //new.youth_academy.coach = QUALITY_AVERAGE;

            MemMatchesFile = null;
            MemMatches = new List<MemMatch>();

            Bets[0] = new List<BetUser>();
            Bets[1] = new List<BetUser>();
            DefaultTeam = new List<int>();
            DefaultStyle = 0;
            DefaultBoost = 0;
        }