// test "create_action/1 kind: ability/merge" { // user = insert(:user) // commander = insert(:commander) // user_data = build(:user_data, %{ // turn: true, // user_id: user.id, // commander_id: commander.id // }) // unit_one = unit_data(AWDS.infantry(), %{ // user_id: user_data.user_id, // health: 17, // coord: build(:coord, %{x: 0, y: 0}), // team: 1 // }) // unit_two = unit_data(AWDS.infantry(), %{ // user_id: user_data.user_id, // unit_id: unit_one.unit_id, // health: 20, // coord: build(:coord, %{x: 0, y: 3}), // team: 1 // }) // map = insert(:map) // game = insert(:game, %{ // weather: "Clear", // map: map, // map_data: map.map_data, // map_type: map.map_type, // unit_data: [unit_one, unit_two], // user_data: [user_data] // }) // unit_one = game.unit_data |> Enum.at(0) // unit_two = game.unit_data |> Enum.at(1) // insert(:game_user, %{game: game, faction: 1}) // insert(:game_user, %{game: game, faction: 2}) // action = build(:action, %{ // kind: "ability", // ability_id: AbilityKind::Merge, // subject_unit_data_id: unit_one.id, // target_unit_data_id: unit_two.id, // game_id: game.id, // user_id: user.id, // move_coords: [ // build(:coord, %{x: 0, y: 1}), // build(:coord, %{x: 0, y: 2}), // build(:coord, %{x: 0, y: 3}) // ] // }) // |> Map.from_struct() // assert {:ok, Action { // game: Game { // unit_data: [ // UnitData {id: unit_two_id, coord: Coord {x: 0, y: 3}, health: 37}, // ] // } // }} = Engine.create_action(action) // assert unit_two.id == unit_two_id // }