Esempio n. 1
0
 public virtual void Visit(FieldBlock block)
 {
 }
Esempio n. 2
0
 public void ReplaceWithField()
 {
     using (Transaction.Create(Root.ActionManager))
     {
         FieldBlock field = new FieldBlock();
         field.Modifiers.SetMany(
             this.Modifiers.GetModifierString());
         field.Name = this.Name;
         this.Replace(field);
     }
 }
Esempio n. 3
0
 public override void Visit(FieldBlock block)
 {
 }
        internal static FieldBlock GetSubBlockFieldBlock(int subblockid)
        {
            FieldBlock fieldBlock   = null;
            int        fieldblockid = 0;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    connection.Open();

                    SqlCommand cmdGetCustomers = new SqlCommand("select FieldBlockID from SubBlock WHERE SubBlockId = @SubBlockId", connection);
                    cmdGetCustomers.Parameters.Add(new SqlParameter("@SubBlockId", subblockid));
                    SqlDataReader reader = cmdGetCustomers.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            fieldblockid = reader.GetInt32(0);
                        }
                    }
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    connection.Open();

                    SqlCommand cmdGetCustomers = new SqlCommand("select * from FieldBlock WHERE FieldBlockID = @FieldBlockID", connection);
                    cmdGetCustomers.Parameters.Add(new SqlParameter("@FieldBlockID", fieldblockid));
                    SqlDataReader reader = cmdGetCustomers.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            fieldBlock = new FieldBlock(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetString(5), null);
                        }
                    }
                }
                catch (SqlException e)
                {
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }

            return(fieldBlock);
        }
        public static void AddFieldBlock(FieldBlock fieldblock)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;

                transaction = connection.BeginTransaction("");

                command.Connection  = connection;
                command.Transaction = transaction;

                try
                {
                    command.CommandText =
                        "Insert into FieldBlock (BlockChar, FieldBlockYear,FieldBlockLength,FieldBlockWidth,Comment) OUTPUT INSERTED.FieldBlockID VALUES (@BlockChar,@FieldBlockYear,@FieldBlockLength,@FieldBlockWidth,@Comment)";
                    command.Parameters.Add(new SqlParameter("@BlockChar", fieldblock.BlockChar));
                    command.Parameters.Add(new SqlParameter("@FieldBlockYear", fieldblock.FieldBlockYear));
                    command.Parameters.Add(new SqlParameter("@FieldBlockLength", fieldblock.FieldBlockLength));
                    command.Parameters.Add(new SqlParameter("@FieldBlockWidth", fieldblock.FieldBlockWidth));
                    command.Parameters.Add(new SqlParameter("@Comment", fieldblock.Comment));
                    int fieldBlockID = (int)command.ExecuteScalar();
                    command.Parameters.Clear();
                    foreach (SubBlock subB in fieldblock.SubBlocks)
                    {
                        command.CommandText = "SP_InsertSubBlock";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add(new SqlParameter("@FieldBlockID", fieldBlockID));
                        command.Parameters.Add(new SqlParameter("@SubBlockChar", subB.SubBlockChar));
                        command.Parameters.Add(new SqlParameter("@AmountOfTrialGroups", subB.AmountOfTrialGroups));
                        command.Parameters.Add(new SqlParameter("@LastNrOfTrialGroup", subB.LastNrOfTrialGroup));
                        command.Parameters.Add(new SqlParameter("@SubBlockLength", subB.SubBlockLength));
                        command.Parameters.Add(new SqlParameter("@SubBlockWidth", subB.SubBlockWidth));
                        command.Parameters.Add(new SqlParameter("@PosL", subB.PosL));
                        command.Parameters.Add(new SqlParameter("@PosW", subB.PosW));
                        command.Parameters.Add(new SqlParameter("@TrialTypeName", subB.SubBlockTrialType.Name));
                        command.Parameters.Add(new SqlParameter("@Comment", subB.Comment));
                        int subBlockID = (int)command.ExecuteScalar();

                        command.Parameters.Clear();

                        foreach (TrialGroup trialG in subB.TrialGroups)
                        {
                            command.CommandText = "SP_InsertTrialGroup";
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.Add(new SqlParameter("@SubBlockID", subBlockID));
                            command.Parameters.Add(new SqlParameter("@CropName", trialG.TrialGroupCrop.Name));
                            command.Parameters.Add(new SqlParameter("@TrialGroupNr", trialG.TrialGroupNr));
                            command.Parameters.Add(new SqlParameter("@Comment", trialG.Comment));
                            int trialGroupID = (int)command.ExecuteScalar();

                            command.Parameters.Clear();
                            if (trialG.Treatments != null)
                            {
                                foreach (Treatment treatment in trialG.Treatments)
                                {
                                    command.CommandText = "SP_InsertTreatment";
                                    command.CommandType = CommandType.StoredProcedure;
                                    command.Parameters.Add(new SqlParameter("@TrialGroupID", trialGroupID));
                                    command.Parameters.Add(new SqlParameter("@TreatmentTypeName", treatment.TreatmentTreatmentType.Name));
                                    if (treatment.TreatmentDate != null)
                                    {
                                        command.Parameters.Add(new SqlParameter("@TreatmentDate", treatment.TreatmentDate));
                                    }
                                    command.Parameters.Add(new SqlParameter("@TreatmentStage", treatment.TreatmentStage));
                                    command.Parameters.Add(new SqlParameter("@Comment", treatment.Comment));
                                    int treatmentID = (int)command.ExecuteScalar();

                                    command.Parameters.Clear();
                                    foreach (TreatmentProduct treatmentP in treatment.Products)
                                    {
                                        command.CommandText = "SP_InsertTreatmentProduct";
                                        command.CommandType = CommandType.StoredProcedure;
                                        command.Parameters.Add(new SqlParameter("@TreatmentID", treatmentID));
                                        command.Parameters.Add(new SqlParameter("@ProductName", treatmentP.TrtProduct.Name));
                                        command.Parameters.Add(new SqlParameter("@ProductDose", treatmentP.ProductDose));
                                        command.Parameters.Add(new SqlParameter("@ProductUnit", treatmentP.ProductUnit.Name));
                                        command.Parameters.Add(new SqlParameter("@DoseLog", treatmentP.DoseLog));
                                        command.ExecuteNonQuery();

                                        command.Parameters.Clear();
                                    }
                                }
                            }
                        }
                    }


                    transaction.Commit();
                    Console.WriteLine("Both records are written to database.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Commit Exception Type: {0}", ex.GetType());
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
                        Console.WriteLine("  Message: {0}", ex2.Message);
                    }
                }
            }
        }
Esempio n. 6
0
 public override void Visit(FieldBlock block)
 {
     WriteIndent();
     Write(block.Modifiers);
     Write(block.Name.TrimEnd(';', ' '));
     WriteSemicolon();
     NewLine();
 }
    public static void Summon(GameObject selectedCard, FieldBlock block, UnitData data1, UnitData data2)
    {
        UnitData data = selectedCard.GetComponent <CardDisplay>().m_CardData;

        Summon(data, block, data1, data2);
    }
Esempio n. 8
0
 public void SetNextElementFieldBlock(FieldBlock fieldBlock)
 {
     this.NextElementFieldBlock = fieldBlock;
 }
Esempio n. 9
0
 public void FieldInteraction(Player pg, FieldBlock myBlock)
 {
     throw new NotImplementedException();
 }
Esempio n. 10
0
 public void Post([FromBody] FieldBlock fieldBlock)
 {
     DataBaseConnector.AddFieldBlock(fieldBlock);
 }
Esempio n. 11
0
        public void PlayerHarvest(Player pg, FieldBlock block)
        {
            Pair <FoodType, int> food = block.Harvest();

            pg.GetInventory().AddFoods(food.GetX(), food.GetY());
        }
    public static List <RankUpCondition> GetAllConditions(UnitData data1, UnitData data2, FieldBlock block)
    {
        List <RankUpCondition> conditions = new List <RankUpCondition>();

        if (data1.m_Owner.m_PlayerID != data2.m_Owner.m_PlayerID)
        {
            return(conditions);
        }

        //add all rank ups from Spirit 1
        conditions.AddRange(data1.m_RankUps);

        //add rank ups with sacrifice from Spirit 2
        foreach (RankUpCondition rankUp in data2.m_RankUps)
        {
            if (rankUp.m_Sacrifice)
            {
                conditions.Add(rankUp);
            }
        }

        PlayerID id     = data1.m_Owner.m_PlayerID;
        Player   player = PlayerManager.Instance.GetPlayer(id);

        int currentMana = player.m_Mana.currentMana;

        FieldBlockType type = block.m_RowType;

        for (int i = conditions.Count - 1; i >= 0; i--)
        {
            UnitData data = conditions[i].m_HighRankSpirit;

            //unique
            if (!player.CheckUniqueUnit(data))
            {
                conditions.RemoveAt(i);
            }
            //mana
            else if (data.m_Cost > currentMana)
            {
                conditions.RemoveAt(i);
            }
            //position
            else if ((type == FieldBlockType.Front && !data.CanBeFrontline) || (type == FieldBlockType.Back && !data.CanBeBackline))
            {
                conditions.RemoveAt(i);
            }
            //condition
            else if (!conditions[i].Check(data1, data2))
            {
                conditions.RemoveAt(i);
            }
        }

        return(conditions);
    }
Esempio n. 13
0
 public TargetOption(FieldBlock b)
 {
     block = b;
 }
Esempio n. 14
0
 public RankUpOption(UnitData highRank, UnitData material1, UnitData material2, FieldBlock position)
 {
     data    = highRank;
     spirit1 = material1;
     spirit2 = material2;
     block   = position;
 }
    public static void SummonWarrior(PlayerID id, UnitData data)
    {
        FieldBlock block = BoardManager.Instance.GetFieldController(id).GetBlockByPosition(FieldBlockType.Center, FieldBlockType.Middle);

        Summon(data, block, id);
    }
 public static bool CheckPosition(Unit unit, FieldBlock block)
 {
     return(CheckPosition(unit.m_Data, block));
 }