示例#1
0
 /// <summary>
 ///     Clears all the global
 /// </summary>
 public static void ClearValues()
 {
     AccountingGroups.Clear();
     CostProfileGroups.Clear();
     CountriesOfOrigin.Clear();
     CustomerIdConversions.Clear();
     ExternalIdTypes.Clear();
     ItemCategories.Clear();
     ItemGroups.Clear();
     ItemIds.Clear();
     ItemIdSuffixes.Clear();
     ItemRecords.Clear();
     Languages.Clear();
     Licenses.Clear();
     LocalItemIds.Clear();
     MetaDescriptions.Clear();
     PricingGroups.Clear();
     ProductCategories.Clear();
     ProductFormats.Clear();
     ProductGoups.Clear();
     ProductLines.Clear();
     Properties.Clear();
     PsStatuses.Clear();
     RequestStatus.Clear();
     SpecialCharacters.Clear();
     TariffCodes.Clear();
     Territories.Clear();
     ToolTips.Clear();
     UpcProductFormatExceptions.Clear();
     Upcs.Clear();
     UserNames.Clear();
     UserRoles.Clear();
     WebCategoryList.Clear();
 }
示例#2
0
 public void AbortGame()
 {
     MainThread.Abort();
     UserNames.Clear();
     server.BroadCastToAll("GRDY|");
     Running   = false;
     IsRunning = false;
     Program.Log("已强制终止主线程");
 }
        //Pre: The map name, the user name, and the elapsed time of the user
        //Post: A boolean for whether the highscore was updated
        //Desc: A method for updating the highscores of a map
        public bool UpdateHighscoresMap(string mapName, string user, float elapsedTime)
        {
            //Temporarily used lists for the names and times
            List <string> tempNames = new List <string>();
            List <float>  tempTimes = new List <float>();

            //If the list of usernames is not null
            if (UserNames != null)
            {
                //Clears the usernames and times for each user
                UserNames.Clear();
                UserTimes.Clear();
            }

            //Checks if the file exists
            if (onlineHelper.CheckFileExists(mapName + FILE_NAME_SUFFIX))
            {
                //Downloads the file
                onlineHelper.DownloadFile(mapName + FILE_PATH_SUFFIX, mapName + FILE_NAME_SUFFIX);

                //Creates a stream reader for the file
                reader = new StreamReader(mapName + FILE_PATH_SUFFIX);

                //Gets the score count using the reader from the file
                int scoreCount = Convert.ToInt32(reader.ReadLine());

                //Loop for every score saved in the file
                for (int i = 0; i < scoreCount; i++)
                {
                    //Adds the neames and times to the lists from the file
                    tempNames.Add(reader.ReadLine());
                    tempTimes.Add((float)Convert.ToDouble(reader.ReadLine()));
                }

                //Closes the stream reader
                reader.Close();

                //Adds the new user and their time
                tempNames.Add(user);
                tempTimes.Add(elapsedTime);

                //Sorts the new times
                SortTimes(tempNames, tempTimes);

                //If the amount of scores saved is greater then the max amount of scores
                if (UserNames.Count > MAX_SCORES)
                {
                    //Removes the last score
                    UserNames.RemoveAt(UserNames.Count - 1);
                    UserTimes.RemoveAt(UserTimes.Count - 1);
                }

                //Creates the stream writer with the file path
                writer = new StreamWriter(mapName + FILE_PATH_SUFFIX);

                //Writes the amount of scores to the file
                writer.WriteLine(UserNames.Count);

                //Loop for every score
                for (int i = 0; i < UserNames.Count; i++)
                {
                    //Writers the user name and it's time to the file
                    writer.WriteLine(UserNames[i]);
                    writer.WriteLine(UserTimes[i]);
                }

                //Closes the file
                writer.Close();

                //If the file was updates
                if (onlineHelper.UpdateFile(mapName + FILE_NAME_SUFFIX, mapName + FILE_PATH_SUFFIX, FILE_TYPE, FILE_DESCRIPTION))
                {
                    //Returns that the file was updateed
                    return(true);
                }
            }
            //If the file does not exist
            else
            {
                //Resets the names and the times for each name
                UserNames = new List <string>();
                UserTimes = new List <float>();

                //Adds the new user and their time
                UserNames.Add(user);
                UserTimes.Add(elapsedTime);

                //A stream writer is created with the path of the current map
                writer = new StreamWriter(mapName + FILE_PATH_SUFFIX);

                //Writes the amount of scores in the file
                writer.WriteLine(UserNames.Count);

                //Writes the new user name and time to the file
                writer.WriteLine(UserNames[0]);
                writer.WriteLine(UserTimes[0]);

                //Closes the stream writer
                writer.Close();

                //If the file was uploaded
                if (onlineHelper.UpdateFile(mapName + FILE_NAME_SUFFIX, mapName + FILE_PATH_SUFFIX, FILE_TYPE, FILE_DESCRIPTION))
                {
                    //Returns that the file was uploaded
                    return(true);
                }
            }

            //Returns that the file was not uploaded
            return(false);
        }
示例#4
0
        public void Work()
        {
            Program.Log("已开局");
            Running = true;
            server.BroadCastToAll("SGRD|");
            CreateCards();
            AnnounceNewGame();
            cards[0].Sort();
            cards[1].Sort();
            cards[2].Sort();
            SendCardList(0);
            SendCardList(1);
            SendCardList(2);
            server.BroadCastToAll("SMSG|即将开局...");
            Thread.Sleep(5000);
            int  now = rand.Next(3);
            bool LandlordSelected = false;

            for (int i = 1; i <= 3; i++)
            {
                AnnounceRound(now);
                if (AskLandlord(now))
                {
                    LandlordSelected = true;
                    break;
                }
                else
                {
                    now++;
                    now %= 3;
                }
            }
            if (LandlordSelected)
            {
                int Landlord = now;
                Program.Log(String.Format("{0}号玩家是地主", now));
                server.BroadCastToAll("PLDL|" + now);
                server.BroadCastToAll("SLOG|" + now + "是地主");
                cards[now].AddRange(baseCard);
                cards[now].Sort();
                SendBaseCard();
                Selection Last  = new Selection();
                int       Owner = now;
                int       time  = 1;
                while (true)
                {
                    AnnounceRound(now);
                    SendCardList(now);
                    Selection selection = GetSelection(now);
                    while (!SelectionOK(now, Last, Owner, selection))
                    {
                        TellSelectionFail(now);
                        selection = GetSelection(now);
                    }
                    if (selection.type != Selection.Type.None)
                    {
                        Last  = selection;
                        Owner = now;
                    }
                    if (selection.type == Selection.Type.Bomb)
                    {
                        time *= 2;
                    }
                    AnnounceSelection(now, selection);
                    foreach (Card i in selection)
                    {
                        cards[now].Remove(i);
                    }
                    if (cards[now].Count == 2 && selection.type != Selection.Type.None)
                    {
                        server.BroadCastToAll("SMSG|" + UserNames[now] + "报双了");
                        server.BroadCastToAll("SLOG|" + UserNames[now] + "报双了");
                    }
                    if (cards[now].Count == 1 && selection.type != Selection.Type.None)
                    {
                        server.BroadCastToAll("SMSG|" + UserNames[now] + "报单了");
                        server.BroadCastToAll("SLOG|" + UserNames[now] + "报单了");
                    }
                    if (cards[now].Count == 0)
                    {
                        AnnounceWinner(now, Landlord, time);
                        break;
                        //server.StopService();
                        //return;
                    }
                    else
                    {
                        SendCardList(now);
                        now++;
                        now %= 3;
                    }
                }
            }
            else
            {
                UserNames.Clear();
            }
            Program.Log("本局结束");
            Running = false;
            UserNames.Clear();
            server.BroadCastToAll("GRDY|");
            //server.StopService();
        }