Exemplo n.º 1
0
        void RunSession(bool write_state)
        {
            BingoGameState s;

            playing_session.BeginPlay();
            // can't check valid, games with no balls are also not valid, but shouldn't end the list.
            while ((s = playing_session.StepReplay(false)).game != null)
            {
                // this begins a thread that plays once.
                // playing_session.Up
                if (s.valid)
                {
                    playing_session.LoadPlayerCards(s);
                    string[] columns = s.game.Name.Split('\t');
                    UpdateStatus("Session: " + this.playing_session.session.session_name + ", Game: " + columns[1].ToString() + " Started");

                    playing_session.Play(s);
                    while (playing_session.Active)
                    {
                        Thread.SpinWait(1);
                    }
                    if (BingoGameCore4.RateRank.Calculate(s))
                    {
                        if (write_state)
                        {
                            StateWriter.DumpState(s, false, true);
                        }
                    }
                    UpdateStatus("Session: " + this.playing_session.session.session_name + ", Game: " + columns[1].ToString() + " Ended");
                }
            }
            UpdateStatus("Updating Session Rate & Rank Data Tables...");
            BingoGameCore4.RateRank.UpdateRanks(playing_session.bingoday, playing_session.session_number);
            UpdateLastStatusLine("Updating Session Rate & Rank Data Tables... Done");
        }
Exemplo n.º 2
0
        /// <summary>
        /// join (particepate Insurance)
        /// </summary>
        /// <param name="PaticipantAddress"></param>
        /// <param name="deposit"></param>
        public void join(Address PaticipantAddress, decimal deposit)
        {
            var participantTableName = GetParticipantListTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue)
            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(participantTableName, out var participantTable))   //happen false
            {
                return;
            }

            if (participantTable.TryGetValue(PaticipantAddress.Encoded, out var value))
            {
                return;
            }
            //Binary values ​​are set in the participant table
            participantTable.SetValue(PaticipantAddress.Encoded, ByteString.Parse("00"));

            var insuranceTableName = GetInsuranceTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue de srue)
            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }
            //Insurance payment
            table.MoveValue(PaticipantAddress, GetContractAddress(), deposit); //from(sender):PaticipantAddress, to(destination):GetContractAddress(), deposit(Monthly insurance money):deposit
        }
Exemplo n.º 3
0
        void DoPlayOne(object param)
        {
            int            game = Convert.ToInt32(param);
            BingoGameState s;

            //while( true )
            {
                s = this.StepTo(game);
                if (s.valid)
                {
                    session.UpdateStatus("Checking game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                    if (StateWriter.CheckState(ref s))
                    {
                        session.UpdateStatus("Playing game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                        Play(s);
                    }
                    else
                    {
                        //MessageBox.Show( "Game:" + s.game.game_number + " in Session:" + ( GameList.session ) + " on " + GameList.bingoday + " has already been rated...\nIgnoring" );
                    }
                }
                //else
                //	break;
            }
            session.UpdateStatus("Rating completed...");
            //status.Refresh();
        }
Exemplo n.º 4
0
            public void SaveSpaceFail(bool differential)
            {
                using var writer = new StateWriter(Store, differential ? CheckpointKind.Differential : CheckpointKind.Full);
                using var logger = new LoggingStateWriter(writer, TextWriter.Null);

                Space.Save(logger);
            }
Exemplo n.º 5
0
        /// <summary>
        /// Disbursement Testament method(遺言状と相続権の払い出し)
        /// </summary>
        /// <param name="RequesterAddress"></param>
        /// <param name="Familyname"></param>
        public void Disbursementtestament(Address RequesterAddress, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }

            //親族チェック
            if (!InheritancemanageTable.TryGetValue(RequesterAddress.Encoded, out var familyname))
            {
                return;
            }

            if (Familyname != (familyname.ToString()))
            {
                return;
            }

            //遺言状トークン情報(トークンID)の取得
            var keyinfo = Familyname + "_Testament";

            if (!InheritancemanageTable.TryGetValue(ByteString.Encode(keyinfo), out var tokenId))
            {
                return;
            }
            var tokeninfo = tokenId.ToString();

            //遺言者の死亡確認
            var Diedinfokey = Familyname + "_DiedTestatorAddress";

            if (!TryGetInternalValue(ByteString.Encode(Diedinfokey), out var TestatorAddress))
            {
                return;
            }

            //相続要求者の鍵一致確認
            var Inheritanceinfokey = Familyname + "_InheritanceAddress";

            if (!TryGetInternalValue(ByteString.Encode(Inheritanceinfokey), out var inheritanceAddress))
            {
                return;
            }
            var InheritanceAddress = PublicKeyAddress.Decode(inheritanceAddress);

            if (InheritanceAddress != RequesterAddress)
            {
                return;
            }

            //NFTテーブルの呼び出し
            var TestamentNFTTableName = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTableName, out var nfttable))
            {
                return;
            }
            nfttable.TransferToken(tokeninfo, RequesterAddress);
        }
Exemplo n.º 6
0
        /// <summary>
        /// SmartContract Instance
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Instantiate(string[] args)
        {
            //Assettableownerkwy = contract admin key
            var contractAdmin = new[]
            {
                GetContractAddress(),
            };

            var insuranceTableName = GetInsuranceTableName();
            //AssetDiscripter(tablename,tracked ,proof,contractadmin(tableowner))
            var assettableDescriptor = new AssetTableDescriptor(insuranceTableName, false, false, contractAdmin);

            var participantListTableName = GetParticipantListTableName();
            //BinarytableDescriptor(tablename,tracks)
            var binarytableDescriptor = new BinaryTableDescriptor(participantListTableName, false);

            try
            {
                //statewrite is environment hold
                StateWriter.AddTable(assettableDescriptor);
                StateWriter.AddTable(binarytableDescriptor);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        void DoPlay()
        {
            BingoGameState s;

            while (true)
            {
                s = this.Step();
                BingoGameEvents.Add(s);
                if (s.valid)
                {
                    session.UpdateStatus("Checking game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                    if (StateWriter.CheckState(ref s))
                    {
                        session.UpdateStatus("Playing game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                        //status.Refresh();
                        BingoMatchEngine.Play(s);
                    }
                    else
                    {
                        //MessageBox.Show( "Game:" + s.game.game_number + " in Session:" + ( GameList.session ) + " on " + GameList.bingoday + " has already been rated...\nIgnoring" );
                    }
                }
                else
                {
                    break;
                }
            }
            if (s.game != null)
            {
                session.UpdateStatus("Game completed " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
            }
            //status.Refresh();
        }
Exemplo n.º 8
0
        protected async override Task OnSaveState(StateWriter state)
        {
            await base.OnSaveState(state);

            state.WriteMember(() => LatestValue);
            state.WriteMember(() => _myNum);
            state.WriteAnnotation("Kobi", 42);
        }
Exemplo n.º 9
0
        /// <summary>
        /// This method deletes a 'State' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'State' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject DeleteState(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Delete StoredProcedure
                DeleteStateStoredProcedure deleteStateProc = null;

                // verify the first parameters is a(n) 'State'.
                if (parameters[0].ObjectValue as State != null)
                {
                    // Create State
                    State state = (State)parameters[0].ObjectValue;

                    // verify state exists
                    if (state != null)
                    {
                        // Now create deleteStateProc from StateWriter
                        // The DataWriter converts the 'State'
                        // to the SqlParameter[] array needed to delete a 'State'.
                        deleteStateProc = StateWriter.CreateDeleteStateStoredProcedure(state);
                    }
                }

                // Verify deleteStateProc exists
                if (deleteStateProc != null)
                {
                    // Execute Delete Stored Procedure
                    bool deleted = this.DataManager.StateManager.DeleteState(deleteStateProc, dataConnector);

                    // Create returnObject.Boolean
                    returnObject.Boolean = new NullableBoolean();

                    // If delete was successful
                    if (deleted)
                    {
                        // Set returnObject.Boolean.Value to true
                        returnObject.Boolean.Value = NullableBooleanEnum.True;
                    }
                    else
                    {
                        // Set returnObject.Boolean.Value to false
                        returnObject.Boolean.Value = NullableBooleanEnum.False;
                    }
                }
            }
            else
            {
                // Raise Error Data Connection Not Available
                throw new Exception("The database connection is not available.");
            }

            // return value
            return(returnObject);
        }
Exemplo n.º 10
0
        /// <summary>
        /// GenerateTest method
        /// </summary>
        /// <param name="participantAddress"></param>
        /// <param name="amount"></param>
        public void GenerateTest(Address participantAddress, decimal amount)
        {
            var insuranceTableName = GetInsuranceTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }

            table.MoveValue(table.VoidAddress, participantAddress, amount);
        }
Exemplo n.º 11
0
        /// <summary>
        /// GenerateAssetTest method
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="amount"></param>
        public void GenerateAssetTest(Address TestatorAddress, decimal amount)
        {
            var HeritageAssetTableName = GetHeritageAssetTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTableName, out var table))
            {
                return;
            }

            table.MoveValue(table.VoidAddress, TestatorAddress, amount);
        }
Exemplo n.º 12
0
        /// <summary>
        /// GenerateTestamentNFTTest method
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="tokenId"></param>
        public void GenerateTestamentNFTTest(Address TestatorAddress, string tokenId)
        {
            var TestamentNFTTableName = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTableName, out var table))
            {
                return;
            }

            table.GenerateToken(tokenId, TestatorAddress);
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method finds a 'State' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'State' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindState(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            State state = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Find StoredProcedure
                FindStateStoredProcedure findStateProc = null;

                // verify the first parameters is a 'State'.
                if (parameters[0].ObjectValue as State != null)
                {
                    // Get StateParameter
                    State paramState = (State)parameters[0].ObjectValue;

                    // verify paramState exists
                    if (paramState != null)
                    {
                        // Now create findStateProc from StateWriter
                        // The DataWriter converts the 'State'
                        // to the SqlParameter[] array needed to find a 'State'.
                        findStateProc = StateWriter.CreateFindStateStoredProcedure(paramState);
                    }

                    // Verify findStateProc exists
                    if (findStateProc != null)
                    {
                        // Execute Find Stored Procedure
                        state = this.DataManager.StateManager.FindState(findStateProc, dataConnector);

                        // if dataObject exists
                        if (state != null)
                        {
                            // set returnObject.ObjectValue
                            returnObject.ObjectValue = state;
                        }
                    }
                }
                else
                {
                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }

            // return value
            return(returnObject);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Inheritance Execution(遺産相続実行)
        /// </summary>
        /// <param name="RequesterAddress"></param>
        /// <param name="Familyname"></param>
        public void InheritanceExecution(Address RequesterAddress, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var inheritancemanageTable))
            {
                return;
            }

            //相続要求者の鍵一致確認(NFTが盗まれたアカウント(鍵)からの要求の対策)
            var Inheritanceinfokey = Familyname + "_InheritanceAddress";

            if (!TryGetInternalValue(ByteString.Encode(Inheritanceinfokey), out var inheritanceAddress))
            {
                return;
            }
            var InheritanceAddress = PublicKeyAddress.Decode(inheritanceAddress);

            if (InheritanceAddress != RequesterAddress)
            {
                return;
            }

            var contractAddress = GetContractAddress();
            //金融資産相続情報の取得から相続まで
            var Assetinfokey = Familyname + "_HeritageAsset";

            if (inheritancemanageTable.TryGetValue(ByteString.Encode(Assetinfokey), out var deposit))
            {
                var amount = Convert.ToDecimal(deposit.ToString());
                var HeritageAssetTableName = GetHeritageAssetTableName();
                if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTableName, out var heritageassettable))
                {
                    return;
                }
                heritageassettable.MoveValue(contractAddress, RequesterAddress, amount);
            }

            //有形資産相続情報の取得から相続まで
            var Tangibleinfokey = Familyname + "_TangibleAsset";

            if (inheritancemanageTable.TryGetValue(ByteString.Encode(Tangibleinfokey), out var tokenId))
            {
                var tokeninfo = tokenId.ToString();
                var TangibleAssetNFTTableName = GetTangibleAssetNFTTableName();
                if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TangibleAssetNFTTableName, out var tangiblenftTable))
                {
                    return;
                }
                tangiblenftTable.TransferToken(tokeninfo, RequesterAddress);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method fetches all 'State' objects.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'State' to delete.
        /// <returns>A PolymorphicObject object with all  'States' objects.
        internal PolymorphicObject FetchAll(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            List <State> stateListCollection = null;

            // Create FetchAll StoredProcedure
            FetchAllStatesStoredProcedure fetchAllProc = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Get StateParameter
                // Declare Parameter
                State paramState = null;

                // verify the first parameters is a(n) 'State'.
                if (parameters[0].ObjectValue as State != null)
                {
                    // Get StateParameter
                    paramState = (State)parameters[0].ObjectValue;
                }

                // Now create FetchAllStatesProc from StateWriter
                fetchAllProc = StateWriter.CreateFetchAllStatesStoredProcedure(paramState);
            }

            // Verify fetchAllProc exists
            if (fetchAllProc != null)
            {
                // Execute FetchAll Stored Procedure
                stateListCollection = this.DataManager.StateManager.FetchAllStates(fetchAllProc, dataConnector);

                // if dataObjectCollection exists
                if (stateListCollection != null)
                {
                    // set returnObject.ObjectValue
                    returnObject.ObjectValue = stateListCollection;
                }
            }
            else
            {
                // Raise Error Data Connection Not Available
                throw new Exception("The database connection is not available.");
            }

            // return value
            return(returnObject);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 相続可能性のある親族に関する情報登録
        /// </summary>
        /// <param name="RelativesAddress">親族の公開鍵</param>
        public void registrelatives(Address RelativesAddress, string Familyname)
        {
            var inheritanceManagementTableName = GetInheritanceManagementTableName();

            //TryGetTableWriter:(StateWriterに登録されたテーブルがあればtrue)
            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(inheritanceManagementTableName, out var managementTable))   //happen false
            {
                return;
            }

            //すでに登録されているかチェック
            if (managementTable.TryGetValue(RelativesAddress.Encoded, out var value))
            {
                return;
            }

            //Binary values ​​are set in the participant table
            managementTable.SetValue(RelativesAddress.Encoded, ByteString.Parse(Familyname));
        }
Exemplo n.º 17
0
            public StateWriterOperation[] SaveSpace(bool differential)
            {
                //
                // NB: Full checkpoints only make sense to be applied to an empty store.
                //

                if (!differential)
                {
                    Store.Data.Clear();
                }

                using var writer = new StateWriter(Store, differential ? CheckpointKind.Differential : CheckpointKind.Full);
                using var logger = new LoggingStateWriter(writer, TextWriter.Null);

                Space.Save(logger);

                logger.CommitAsync().GetAwaiter().GetResult();

                Space.OnSaved();

                return(writer.GetLog());
            }
Exemplo n.º 18
0
        /// <summary>
        /// Deposit Testament NFT method(遺言状をスマートコントラクトにあづける)
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="Familyname"></param>
        public void deposittestamentNFT(string tokenId, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }
            var keyinfo = Familyname + "_Testament";

            //スマートコントラクトに預けた〇〇家の遺言状情報の登録
            InheritancemanageTable.SetValue(ByteString.Encode(keyinfo), ByteString.Encode(tokenId));

            var TestamentNFTTable = GetTestamentNFTTableName();

            if (!StateWriter.TryGetTableWriter <INFTTableWriter>(TestamentNFTTable, out var Table))
            {
                return;
            }

            Table.TransferToken(tokenId, GetContractAddress());
        }
Exemplo n.º 19
0
        /// <summary>
        /// SmartContract Instance
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override bool Instantiate(string[] args)
        {
            //Assettableownerkwy = contract admin key
            var contractAdmin = new[]
            {
                GetContractAddress(),
            };

            var heritageAssetTableName = GetHeritageAssetTableName();
            //AssetDiscripter(tablename,tracked ,proof,contractadmin(tableowner))
            var assettableDescriptor = new AssetTableDescriptor(heritageAssetTableName, false, false, contractAdmin);

            var tangibleAssetNFTTableName = GetTangibleAssetNFTTableName();
            //NFTDiscripter(tablename,tracked ,proof,contractadmin(tableowner))
            var NFTtangibleassetDescripter = new NFTTableDescriptor(tangibleAssetNFTTableName, false, false, contractAdmin);

            var testamentNFTTableName = GetTestamentNFTTableName();
            //NFTDiscripter(tablename,tracked ,proof,contractadmin(tableowner))
            var NFTTestamentDiscripter = new NFTTableDescriptor(testamentNFTTableName, false, false, contractAdmin);

            var inheritanceManagementTableName = GetInheritanceManagementTableName();
            //BinarytableDescriptor(tablename,tracks)
            var binarytableDescriptor = new BinaryTableDescriptor(inheritanceManagementTableName, false);

            try
            {
                //statewrite is environment hold
                StateWriter.AddTable(assettableDescriptor);
                StateWriter.AddTable(NFTtangibleassetDescripter);
                StateWriter.AddTable(NFTTestamentDiscripter);
                StateWriter.AddTable(binarytableDescriptor);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// vote method
        /// </summary>
        /// <param name="ParticipantAddress"></param>
        public void vote(Address ParticipantAddress)
        {
            var participantTableName = GetParticipantListTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(participantTableName, out var participantTable))   //happen false
            {
                return;
            }

            if (!participantTable.TryGetValue(ParticipantAddress.Encoded, out var value))
            {
                return;
            }

            participantTable.SetValue(ParticipantAddress.Encoded, ByteString.Parse("01"));

            //confirm number of participant votes

            var insuranceTableName = GetInsuranceTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(insuranceTableName, out var table))
            {
                return;
            }
            // Can pay insurance amount?
            var contractAddress = GetContractAddress();

            if (!TryGetInternalValue(ByteString.Encode("beneficiaryAddress"), out var address))
            {
                return;
            }

            var beneficiaryAddress = PublicKeyAddress.Decode(address);

            decimal amount = 100m;

            table.MoveValue(contractAddress, beneficiaryAddress, amount);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Deposit HeritageAsset method (現金、預金の財産をスマートコントラクトに預ける)
        /// </summary>
        /// <param name="TestatorAddress"></param>
        /// <param name="deposit"></param>
        /// <param name="Familyname"></param>
        public void depositheritageasset(Address TestatorAddress, decimal deposit, string Familyname)
        {
            var InheritanceManagement = GetInheritanceManagementTableName();

            if (!StateWriter.TryGetTableWriter <IBinaryTableWriter>(InheritanceManagement, out var InheritancemanageTable))
            {
                return;
            }
            var keyinfo = Familyname + "_HeritageAsset";
            var amount  = Convert.ToString(deposit);

            //スマートコントラクトに預けた〇〇家の資産枚数を登録
            InheritancemanageTable.SetValue(ByteString.Encode(keyinfo), ByteString.Encode(amount));

            var HeritageAssetTable = GetHeritageAssetTableName();

            if (!StateWriter.TryGetTableWriter <IAssetTableWriter>(HeritageAssetTable, out var Table))   //happen false
            {
                return;
            }

            Table.MoveValue(TestatorAddress, GetContractAddress(), deposit);
        }
Exemplo n.º 22
0
		public static void UpdateRanks( DateTime day_in_week, int session )
		{
			if( input_db != null )
			{
				long week_id = StateWriter.GetWeekID( day_in_week, session );
				input_db.KindExecuteNonQuery( "replace into called_game_player_rank (card,session,bingoday,week_id,pack_set_id,game_count,total_points)"
						+ " SELECT card,session,bingoday,"+week_id+",pack_set_id,count(*) as game_count,sum(total_points) as total_points"
						+ " FROM called_game_player_rank2 where "
					    //+ (true?"pack_set_id=1":"pack_set_id>0")
						+ " card<>'000000000000000000'"
						//+ " and session=" + playing_session.session_number
						+ " and " + String_Utilities.BuildSessionRangeCondition( null, day_in_week, session )
						//+ " and bingoday=" + MySQLDataTable.MakeDateOnly( playing_session.bingoday )
						+ " group by card,pack_set_id,session,bingoday order by bingoday,session,card,pack_set_id"
						);

				if( use_bonus_points )
				{
					MySQLDataTable table = new MySQLDataTable( input_db, "select * from rate_rank_bonus_points" );
					MySQLDataTable totals = new MySQLDataTable( input_db, "select * from called_game_player_rank where bingoday="+DsnSQLUtil.MakeDateOnly( input_db, day_in_week ) +" and session="+session+" order by total_points desc" );
					if( totals != null && ( totals.Rows.Count > 0 ) )
					{
						int place_num;
						foreach( DataRow row in table.Rows )
						{
							place_num = Convert.ToInt32( row["place_in_session"] );
							input_db.KindExecuteNonQuery( "replace into called_game_player_rank_bonus (card,week_id,bonus_points,bingoday,session)values("
								+ input_db.sql_value_quote_open + totals.Rows[place_num - 1]["card"] + input_db.sql_value_quote_close + "," 
								+ week_id + ","
								+ row["bonus_points"].ToString() + ","
								+ DsnSQLUtil.MakeDateOnly( input_db, day_in_week ) + ","
								+ session 
								+ ")" );
						}
					}
				}
				if( use_bonus_points )
				{
					input_db.KindExecuteNonQuery(
						"replace into called_game_player_rank_partial (card,session,bingoday,total_points,week_id)"
	+ "select a.card,a.session,a.bingoday,a.total_points+sum(IF(ISNULL(c.bonus_points),0,c.bonus_points)),a.week_id from called_game_player_rank as a left"
	+ " join called_game_player_rank as b on a.card=b.card and a.week_id=b.week_id and a.total_points<b.total_points"
	+ " left join called_game_player_rank_bonus as c on a.card=c.card "
	+ " where b.card is null and a.week_id=" + week_id
	+ " group by a.card,a.session,a.bingoday,a.total_points,a.week_id"
					);
				}
				else
				{
					input_db.KindExecuteNonQuery(
						"replace into called_game_player_rank_partial (card,session,bingoday,total_points,week_id)"
	+ "select a.card,a.session,a.bingoday,a.total_points,a.week_id from called_game_player_rank as a left"
	+ " join called_game_player_rank as b on a.card=b.card and a.week_id=b.week_id and a.total_points<b.total_points"
	+ " where b.card is null and a.week_id=" + week_id
					);
				}
#if asdfasdf	
					"replace into called_game_player_rank_partial(card,session,bingoday,week_id,total_points)"
								+ " select card,session,bingoday,week_id,max(total_points) as total_points"
								+ " from called_game_player_rank"
								+ " where week_id=" + week_id 
								+ " group by bingoday,session,card"
						);
#endif
			}
		}
Exemplo n.º 23
0
        void EltaninReceiver_GameChanged(int new_Game)
        {
            //this needs to have an option.
            if (true)
            {
                return;
            }

            //----------------------------------------------
            // FIX
            //----------------------------------------------
            if (playing_session == null)
            {
                return;
            }
            Log.log("New game " + new_Game);
            if (new_Game != old_game)
            {
                if (old_game > 0)
                {
                    UpdateStatus("Reloading players in session "
                                 + playing_session.session_number
                                 + " and game "
                                 + old_game);

                    try
                    {
                        //playing_session.PlayerList
                        //playing_session.ReloadPlayers(/* pack_sequence */); // make sure the players are up to date...

                        /*
                         * for( int p = 0; p < 60; p++ )
                         *  playing_session.PlayerList.Add( new BingoPlayer() );
                         */
                        BingoGameState s = playing_session.StepToReplay(old_game);
                        if (s.valid)
                        {
                            UpdateStatus("Playing session "
                                         + playing_session.session_number
                                         + " and game "
                                         + old_game);
                            playing_session.Play(s);
                            while (playing_session.Active)
                            {
                                Thread.SpinWait(1);
                            }
                            UpdateStatus("Calculating session "
                                         + playing_session.session_number
                                         + " and game "
                                         + old_game);
                            if (BingoGameCore4.RateRank.Calculate(s))
                            {
                                UpdateStatus("Writing session "
                                             + playing_session.session_number
                                             + " and game "
                                             + old_game);
                                StateWriter.DumpState(s, false, false);
                            }
                            else
                            {
                                UpdateStatus("Game did not get ranked, not writing.");
                            }
                        }
                        else
                        {
                            UpdateStatus("Skiping game... not playing it.");
                        }
                    }
                    catch (Exception e)
                    {
                        Log.log("Outermost catcher caught exception - " + e.StackTrace);
                        Log.log("Timer will resume at least...");
                        Log.log(e.Message);
                    }
                }
                old_game = new_Game;
            }
            // Scan prior game...

            //throw new Exception( "The method or operation is not implemented." );
        }
Exemplo n.º 24
0
        protected async override Task OnSaveState(StateWriter writer)
        {
            await base.OnSaveState(writer);

            writer.WriteMember(() => PreservedData);
        }
Exemplo n.º 25
0
        void check_winner_Tick(object sender, EventArgs e)
        {
            Log.log("Tick.");
            check_winner.Stop();
            timer_gameEventDataSet.FillUnprocessed(10);
            {
                if (timer_gameEventDataSet.GamesProcessed.Rows.Count > 0)
                {
                    complete = false;
                    // if playing session is not initialized, a warning is thrown for this loop.

                    foreach (DataRow row in timer_gameEventDataSet.GamesProcessed.Rows)
                    {
                        DataRow GameEventRow = row.GetParentRow("game_is_processed");
                        int     row_session  = Convert.ToInt32(GameEventRow["session"]);
                        //if( this_session == null || playing_session.session_number != row_session )
                        {
                            SetupNewSession(Convert.ToDateTime(GameEventRow["bingoday"]), Convert.ToInt32(GameEventRow["session"]));

                            this_session.StatusUpdate += UpdateStatus;

                            UpdateStatus("Reloading players in session " + playing_session.session_number);
                            // each session has one set of players...
                            // playing_session.ReloadPlayers();
                        }

                        // this has game number in it...
                        BingoGameState[] states = playing_session.StepToReplay(GameEventRow);
                        if (states != null)
                        {
                            UpdateStatus("Playing session "
                                         + playing_session.session_number
                                         );
                            foreach (BingoGameState game_state in states)
                            {
                                // bingo game state contains the BingoGameEvent
                                // so part of initializiation is the Bingogaemevent from the row ... already exists...
                                playing_session.DoPlayState(game_state);
                                //playing_session.Play( game_state );
                                if (BingoGameCore4.RateRank.Calculate(game_state))
                                {
                                    //StateWriter.WritePerCardStatistics = true;
                                    //StateWriter.WritePlayerPackBreakdown = true;
                                    //    StateWriter.
                                    StateWriter.DumpState(game_state, false, false);
                                }
                            }
                            UpdateStatus("Played session (wrote results)"
                                         + playing_session.session_number
                                         );
                        }
                        row["processed"] = true;
                        timer_gameEventDataSet.GamesProcessed.CommitChanges();
                    }
                }
                else
                {
                    if (!complete)
                    {
                        UpdateStatus("Everything Complete.");
                        complete = true;
                    }
                }
            }
            check_winner.Start();
            // select from prize_validations, see if anything is new.

            // step to game, and play.
        }