// fn set_ammo(UnitData {weapon_data: weapon_data} = unit_data, id, count) {
    //   weapon =
    //     weapon_data
    //     |> Enum.find(&(&1.weapon_id == id))
    //     |> Map.put(:ammo, count)

    //   weapon_data =
    //     weapon_data
    //     |> Enum.reject(&(&1.weapon_id == id))

    //   UnitData {unit_data | weapon_data: [weapon | weapon_data]}
    // }

    // test "create_action/1 kind: ability/repair" {
    //   user = insert(:user)
    //   commander = insert(:commander)
    //   user_data = build(:user_data, %{
    //     turn: true,
    //     user_id: user.id,
    //     commander_id: commander.id
    //   })
    //   mech_data = unit_data(AWDS.mech(), %{
    //     health: 54,
    //     fuel: 0,
    //     user_id: user_data.user_id,
    //     coord: build(:coord, %{x: 0, y: 0})
    //   })
    //   mech_data = set_ammo(mech_data, "bz", 0)

    //   black_boat_data = unit_data(AWDS.black_boat(), %{
    //     user_id: user_data.user_id,
    //     coord: build(:coord, %{x: 0, y: 1})
    //   })

    //   map = insert(:map)
    //   game = insert(:game, %{
    //     map: map,
    //     map_data: map.map_data,
    //     map_type: map.map_type,
    //     user_data: [user_data],
    //     unit_data: [black_boat_data, mech_data]
    //   })

    //   black_boat_data = game.unit_data |> Enum.at(0)
    //   mech_data = 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::Repair,
    //     subject_unit_data_id: black_boat_data.id,
    //     target_unit_data_id: mech_data.id,
    //     game_id: game.id,
    //     user_id: user.id
    //   })
    //   |> Map.from_struct()

    //   assert {:ok, Action {
    //     game: Game {
    //       unit_data: [
    //         UnitData {
    //           id: mech_data_id, health: 64, fuel: 70,
    //           weapon_data: [
    //             WeaponData {weapon_id: "mg", ammo: nil},
    //             WeaponData {weapon_id: "bz", ammo: 3}
    //           ]
    //         },
    //         UnitData {state: "exhausted"}
    //       ]
    //     }
    //   }} = Engine.create_action(action)
    //   assert mech_data.id == mech_data_id
    // }