Пример #1
0
    public Tuple <bool, List <string> > login_player(string name, string hashed_password, int conn_id, GAME title)
    {
        if (!login_table.Keys.Contains(name))
        {
            return(new Tuple <bool, List <string> >(false, new List <string>()));
        }
        if (login_table[name].hashed_password != hashed_password)
        {
            return(new Tuple <bool, List <string> >(false, new List <string>()));
        }

        if (player_table.Values.ToList().Any(status => status.name == name))
        {
            return(new Tuple <bool, List <string> >(false, new List <string>()));
        }

        if (player_table.Keys.Contains(conn_id))
        {
            return(new Tuple <bool, List <string> >(false, new List <string>()));
        }

        player_table[conn_id] = new Connection_status(name, conn_id);
        player_table[conn_id].current_game = title;
        party_table[conn_id] = new Party_info(conn_id);


        return(new Tuple <bool, List <string> >(true,
                                                login_table.Values.Where(p => p.requested_friends.Contains(name)).Select(p => p.name).ToList()));
    }
Пример #2
0
    public bool login_player(string name, string hashed_password, int conn_id)
    {
        if (login_table[name].hashed_password != hashed_password)
        {
            return(false);
        }

        if (player_table.Values.ToList().Any(status => status.name == name))
        {
            return(false);
        }

        if (player_table.Keys.Contains(conn_id))
        {
            return(false);
        }

        player_table[conn_id] = new Connection_status(name, conn_id);
        party_table[conn_id]  = new Party_info(conn_id);

        return(true);
    }
Пример #3
0
    public void inform_player_of_friends(Action <int, List <connection_struct> > send)
    {
        List <connection_struct> css;

        foreach (int conn_id in player_table.Keys)
        {
            css = new List <connection_struct>();
            foreach (string friend in login_table[player_table[conn_id].name].friends)
            {
                Connection_status status = player_table.Values.Where(p => p.name == friend).FirstOrDefault();
                if (status != null)
                {
                    bool is_in_party = party_table[status.conn_id].players.Any(_ => true);
                    //if they are the sole member, then they are the leader
                    css.Add(new connection_struct(friend, status.is_in_game, is_in_party, status.current_game, true, conn_id));
                }
                else
                {
                    css.Add(new connection_struct(friend, false, false, (GAME)(-1), false, conn_id));
                }
            }
            send(conn_id, css);
        }
    }