Esempio n. 1
0
        public async Task ShowField_should_create_events_and_update_state_for_array()
        {
            var command = new ShowField {
                ParentFieldId = 1, FieldId = 2
            };

            await ExecuteCreateAsync();
            await ExecuteAddArrayFieldAsync();
            await ExecuteAddFieldAsync(fieldName, 1);
            await ExecuteHideFieldAsync(2, 1);

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(new EntitySavedResult(4));

            Assert.False(GetField(1).IsHidden);
            Assert.False(GetNestedField(1, 2).IsHidden);

            LastEvents
            .ShouldHaveSameEvents(
                CreateEvent(new FieldShown {
                ParentFieldId = arrayId, FieldId = nestedId
            })
                );
        }
Esempio n. 2
0
 internal override void EndTurn()
 {
     buy    = 1;
     action = 1;
     Money  = 0;
     DoTurn();
     CardTrash();
     GetForm().Invoke(new TrashVisbleDelegate(TrashVisible));
     for (int i = 0; i < ShowHand.Count; i++)
     {
         GetForm().Invoke(new TrashDelegate(ShowHand[i].Trash), 740, 10 + 120 * num);
     }
     for (int i = 0; i < ShowField.Count; i++)
     {
         GetForm().Invoke(new TrashDelegate(ShowField[i].Trash), 740, 10 + 120 * num);
     }
     BuyList.Clear();
     ShowField.Clear();
     ShowHand.Clear();
     DrawCard(5);
     GetForm().Invoke(new SetCountDelegate(SetCount), Deck.Count);
     //
     //
     //
     //
     //  AI作れ
     //
     //
     //
     //
     //
 }
Esempio n. 3
0
 internal override void EndTurn()
 {
     GetForm().Invoke(new AllSupplyClickDelegate(form1.AllSupplyClickOff));
     GetForm().Invoke(new AllSupplyClickDelegate(ShowDeck.CardClickOff));
     CardTrash();
     GetForm().Invoke(new TrashVisbleDelegate(TrashVisible));
     for (int i = 0; i < ShowHand.Count; i++)
     {
         GetForm().Invoke(new TrashDelegate(ShowHand[i].Trash), 20, 540);
     }
     for (int i = 0; i < ShowField.Count; i++)
     {
         GetForm().Invoke(new TrashDelegate(ShowField[i].Trash), 20, 540);
     }
     ShowField.Clear();
     ShowHand.Clear();
     DrawCard(5);
     GetForm().Invoke(new SetTurnDelegate(SetTurn));
     ChangeTurn();
     if (form1.EndGameFlag())
     {
         GetForm().Invoke(new EndGameDelegate(form1.EndGame));
     }
     else
     {
         EnemyTurn();
     }
     if (!form1.EndGameFlag())
     {
         GetForm().Invoke(new AllSupplyClickDelegate(ShowDeck.CardClickOn));
         GetForm().Invoke(new AllSupplyClickDelegate(form1.AllSupplyClickOn));
         ChangeTurn();
     }
 }
Esempio n. 4
0
        public void CanShow_should_throw_exception_if_not_found()
        {
            var command = new ShowField {
                FieldId = 3
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardSchemaField.CanShow(schema_0, command));
        }
Esempio n. 5
0
        public void CanShow_should_throw_exception_if_already_shown()
        {
            var command = new ShowField {
                FieldId = 1
            };

            Assert.Throws <DomainException>(() => GuardSchemaField.CanShow(schema_0, command));
        }
Esempio n. 6
0
        public void CanShow_should_throw_exception_if_ui_field()
        {
            var command = new ShowField {
                FieldId = 4
            };

            Assert.Throws <DomainException>(() => GuardSchemaField.CanShow(command, schema_0));
        }
Esempio n. 7
0
        public SchemaDomainObject ShowField(ShowField command)
        {
            VerifyCreatedAndNotDeleted();

            RaiseEvent(command, new FieldShown());

            return(this);
        }
Esempio n. 8
0
        protected Task On(ShowField command, CommandContext context)
        {
            return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s =>
            {
                GuardSchemaField.CanShow(s.Snapshot.SchemaDef, command);

                s.ShowField(command);
            }));
        }
Esempio n. 9
0
        public void CanShow_should_not_throw_exception_if_hidden()
        {
            var command = new ShowField {
                FieldId = 1
            };

            schema.FieldsById[1].Hide();

            GuardSchemaField.CanShow(schema, command);
        }
Esempio n. 10
0
        public async Task <IActionResult> ShowField(string app, string name, long id)
        {
            var command = new ShowField {
                FieldId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Esempio n. 11
0
        public async Task <IActionResult> ShowNestedField(string app, string name, long parentId, long id)
        {
            var command = new ShowField {
                ParentFieldId = parentId, FieldId = id
            };

            var response = await InvokeCommandAsync(app, command);

            return(Ok(response));
        }
        public async Task <IActionResult> ShowField(string app, string name, long id)
        {
            var command = new ShowField {
                FieldId = id
            };

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
Esempio n. 13
0
        public void CanShow_should_throw_exception_if_locked()
        {
            var command = new ShowField {
                FieldId = 1
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Lock());

            Assert.Throws <DomainException>(() => GuardSchemaField.CanShow(command, schema_1));
        }
Esempio n. 14
0
        public void CanShow_should_not_throw_exception_if_hidden()
        {
            var command = new ShowField {
                FieldId = 1
            };

            var schema_1 = schema_0.HideField(1);

            GuardSchemaField.CanShow(schema_1, command);
        }
Esempio n. 15
0
        public static void CanShow(Schema schema, ShowField command)
        {
            Guard.NotNull(command, nameof(command));

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (!field.IsHidden)
            {
                throw new DomainException("Schema field is already visible.");
            }
        }
Esempio n. 16
0
        public static void CanShow(ShowField command, Schema schema)
        {
            Guard.NotNull(command);

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (!field.IsForApi(true))
            {
                throw new DomainException("UI field cannot be shown.");
            }
        }
Esempio n. 17
0
        public static void CanShow(ShowField command, Schema schema)
        {
            Guard.NotNull(command, nameof(command));

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (!field.IsForApi(true))
            {
                throw new DomainException(T.Get("schemas.uiFieldCannotBeShown"));
            }
        }
Esempio n. 18
0
        public SchemaDomainObject ShowField(ShowField command)
        {
            Guard.NotNull(command, nameof(command));

            VerifyCreatedAndNotDeleted();

            SchemaFieldGuard.GuardCanShow(schema, command.FieldId);

            RaiseEvent(command, new FieldShown());

            return(this);
        }
Esempio n. 19
0
        private void Button_MouseClick(object sender, MouseEventArgs e)
        {
            if (!timer.Enabled)
            {
                return;
            }
            Button bttnClick = sender as Button;

            if (bttnClick == null)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (bttnClick.Text == "x")
                {
                    bttnClick.Text = "";
                }
                else
                {
                    bttnClick.Text = "x";
                }
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                string[] split = bttnClick.Name.Split(new Char[] { ' ' });

                int x = System.Convert.ToInt32(split[0]);
                int y = System.Convert.ToInt32(split[1]);



                if (game.Board.GameBoard.Grid[x, y] == -1)
                {
                    lose_b.Visible = false;
                    EndGame end = new EndGame(game);
                    timer.Enabled = false;
                }

                ShowField show = new ShowField(x, y, game);
                bttnClick.Visible = false;
            }
        }
Esempio n. 20
0
        public async Task ShowField_should_create_events_and_update_state()
        {
            var command = new ShowField { FieldId = 1 };

            await ExecuteCreateAsync();
            await ExecuteAddFieldAsync(fieldName);
            await ExecuteHideFieldAsync(1);

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.False(GetField(1).IsHidden);

            LastEvents
                .ShouldHaveSameEvents(
                    CreateEvent(new FieldShown { FieldId = fieldId })
                );
        }
Esempio n. 21
0
        private bool FieldIsVisible(Editor.Field field)
        {
            try
            {
                Item templateFieldItem = GetTemplateFieldItem(field, args.Item.Database);

                if (templateFieldItem == null)
                {
                    return(true);
                }

                ShowField showField = ShowField.Always;

                try
                {
                    showField = ParseShowField(new ID(templateFieldItem.Fields[Items.ShowField].Value));
                }
                catch { }

                if (showField.Equals(ShowField.Always))
                {
                    return(true);
                }
                if (showField.Equals(ShowField.Never))
                {
                    return(false);
                }
                if (showField.Equals(ShowField.WhenShowingStandardFields) && (!UserOptions.ContentEditor.ShowSystemFields))
                {
                    return(false);
                }
            }
            catch { }

            return(true);
        }
Esempio n. 22
0
        public async Task ShowField_should_create_events_and_update_nested_field_hidden_flag()
        {
            var command = new ShowField {
                ParentFieldId = 1, FieldId = 2
            };

            await ExecuteCreateAsync();
            await ExecuteAddArrayFieldAsync();
            await ExecuteAddFieldAsync(fieldName, 1);
            await ExecuteHideFieldAsync(2, 1);

            var result = await PublishIdempotentAsync(command);

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.False(GetNestedField(1, 2).IsHidden);

            LastEvents
            .ShouldHaveSameEvents(
                CreateEvent(new FieldShown {
                ParentFieldId = arrayId, FieldId = nestedId
            })
                );
        }
Esempio n. 23
0
 public void ShowField(ShowField command)
 {
     RaiseEvent(command, new FieldShown());
 }
 protected Task On(ShowField command, CommandContext context)
 {
     return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.ShowField(command)));
 }
Esempio n. 25
0
 private void ShowField(ShowField command)
 {
     Raise(command, new FieldShown());
 }