<% captain = team == 1 ? @gather.captain1 : @gather.captain2 %>
<% pick = false %>

<h4>
  <%= if team.nil? then "Lobby" else team == 1 ? "Marines" : "Aliens" end %>
</h4>

<%= form_tag("/gathers/pick/#{@gather.id}") do %>
  <ul class="gatherers">
    <% @gather.gatherers.ordered.team(team).each do |gatherer| %>
      <li>
        <% if @gatherer and gatherer.can_update? cuser, { team: @gatherer.team } %>
          <% pick = true %>
          <%= radio_button_tag :player, gatherer.id %><%= flag gatherer.user.country %>
          <%= namelink gatherer.user %>

        <% else %>
          <%= flag(gatherer.user.country) if gatherer.user && gatherer.user.country %>

          <% if gatherer == captain and gatherer.team == gatherer.gather.turn %>
            <%= icon 'chevron-right' %>
          <% end %>

          <%= namelink gatherer.user %>

          <% if gatherer == captain %>
            <span class="captain">
              <%= icon('star') %>
            </span>
          <% end %>
        <% end %>
      </li>
    <% end %>
    <% if pick %>
      <a class="button tiny">Pick</a>
    <% end %>
  </table>
<% end %>
