File: ejer2.cpp

package info (click to toggle)
teg 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,036 kB
  • sloc: cpp: 16,819; xml: 1,313; makefile: 268; sh: 195; ansic: 112
file content (67 lines) | stat: -rw-r--r-- 1,935 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Tenes Empanadas Graciela
 *
 * Copyright (C) 2000 Ricardo Quesada
 *
 * Author: Ricardo Calixto Quesada <rquesada@core-sdi.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; only version 2 of the License
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

#include <filesystem>
#include "net.h"
#include "protocol.h"
#include "fcintl.h"
#include "client.h"

namespace teg::client
{

static int last_country = -1;

TEG_STATUS ejer2_out(int country)
{
	if(g_countries[ country ].numjug == WHOAMI()) {
		if(ESTADO_ES(PLAYER_STATUS_TARJETA)) {
			if(!tarjeta_es_usada(&g_countries[ country ].tarjeta)) {
				tarjeta_usar(&g_countries[ country ].tarjeta);
				last_country = country;
				net_printf(g_game.fd, TOKEN_EJER2"=%d\n", country);
				return TEG_STATUS_SUCCESS;
			} else {
				textmsg(M_ERR, _("Error, the 2 armies where placed before"));
				return TEG_STATUS_ERROR;
			}
		} else {
			textmsg(M_ERR, _("Error, it's not the time to put 2 armies."));
			return TEG_STATUS_ERROR;
		}
	} else {
		textmsg(M_ERR, _("Error, '%s' isnt one of your countries"), g_countries[country].name);
		return TEG_STATUS_ERROR;
	}
	return TEG_STATUS_ERROR;
}

TEG_STATUS ejer2_restore_from_error()
{
	if(last_country != -1) {
		tarjeta_desusar(&g_countries[ last_country ].tarjeta);
		callbacks::gui_tarjeta(-1);
		last_country = -1;
		return TEG_STATUS_SUCCESS;
	}
	return TEG_STATUS_ERROR;
}

}