mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-24 23:53:54 -07:00
initial commit
This commit is contained in:
commit
a11f93df4d
99 changed files with 7493 additions and 0 deletions
311
servatrice/Doxyfile
Executable file
311
servatrice/Doxyfile
Executable file
|
|
@ -0,0 +1,311 @@
|
|||
# Doxyfile 1.5.5-KDevelop
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = servertest
|
||||
PROJECT_NUMBER = 0.1
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = /home/brukie/
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = /home/brukie/servertest
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.d \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.idl \
|
||||
*.odl \
|
||||
*.cs \
|
||||
*.php \
|
||||
*.php3 \
|
||||
*.inc \
|
||||
*.m \
|
||||
*.mm \
|
||||
*.dox \
|
||||
*.py \
|
||||
*.f90 \
|
||||
*.f \
|
||||
*.vhd \
|
||||
*.vhdl \
|
||||
*.C \
|
||||
*.CC \
|
||||
*.C++ \
|
||||
*.II \
|
||||
*.I++ \
|
||||
*.H \
|
||||
*.HH \
|
||||
*.H++ \
|
||||
*.CS \
|
||||
*.PHP \
|
||||
*.PHP3 \
|
||||
*.M \
|
||||
*.MM \
|
||||
*.PY \
|
||||
*.F90 \
|
||||
*.F \
|
||||
*.VHD \
|
||||
*.VHDL \
|
||||
*.C \
|
||||
*.H \
|
||||
*.tlh \
|
||||
*.diff \
|
||||
*.patch \
|
||||
*.moc \
|
||||
*.xpm \
|
||||
*.dox
|
||||
RECURSIVE = yes
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NONE
|
||||
TREEVIEW_WIDTH = 250
|
||||
FORMULA_FONTSIZE = 10
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = yes
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE = servertest.tag
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
DOT_FONTNAME = FreeSans
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = YES
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
340
servatrice/copying
Executable file
340
servatrice/copying
Executable file
|
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
32
servatrice/servertest.pro
Executable file
32
servatrice/servertest.pro
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
######################################################################
|
||||
# Automatically generated by qmake (2.01a) Fr Sep 5 18:02:29 2008
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET =
|
||||
DEPENDPATH += . src
|
||||
INCLUDEPATH += . src
|
||||
|
||||
CONFIG += qt thread
|
||||
QT += network
|
||||
QT -= gui
|
||||
|
||||
# Input
|
||||
HEADERS += src/testserver.h src/testservergame.h src/testserversocket.h \
|
||||
src/playerzone.h \
|
||||
src/testcard.h \
|
||||
src/version.h \
|
||||
src/counter.h \
|
||||
src/testrandom.h \
|
||||
src/testservergamethread.h \
|
||||
src/returnmessage.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/testserver.cpp \
|
||||
src/testservergame.cpp \
|
||||
src/testserversocket.cpp \
|
||||
src/playerzone.cpp \
|
||||
src/testcard.cpp \
|
||||
src/counter.cpp \
|
||||
src/testrandom.cpp \
|
||||
src/testservergamethread.cpp \
|
||||
src/returnmessage.cpp
|
||||
21
servatrice/src/counter.cpp
Normal file
21
servatrice/src/counter.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 "counter.h"
|
||||
|
||||
37
servatrice/src/counter.h
Normal file
37
servatrice/src/counter.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef COUNTER_H
|
||||
#define COUNTER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Counter {
|
||||
protected:
|
||||
QString name;
|
||||
int count;
|
||||
public:
|
||||
Counter(QString _name, int _count = 0) : name(_name), count(_count) { }
|
||||
~Counter() { }
|
||||
int getCount() { return count; }
|
||||
void setCount(int _count) { count = _count; }
|
||||
QString getName() const { return name; }
|
||||
};
|
||||
|
||||
#endif
|
||||
33
servatrice/src/main.cpp
Normal file
33
servatrice/src/main.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 <QCoreApplication>
|
||||
#include "testserver.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
TestServer server;
|
||||
server.listen(QHostAddress::Any, 4747);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
86
servatrice/src/playerzone.cpp
Normal file
86
servatrice/src/playerzone.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 "playerzone.h"
|
||||
|
||||
PlayerZone::PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _id_access)
|
||||
: name(_name), has_coords(_has_coords), is_public(_is_public), id_access(_id_access)
|
||||
{
|
||||
}
|
||||
|
||||
PlayerZone::~PlayerZone()
|
||||
{
|
||||
qDebug(QString("PlayerZone destructor: %1").arg(name).toLatin1());
|
||||
clear();
|
||||
}
|
||||
|
||||
void PlayerZone::shuffle(TestRandom *rnd)
|
||||
{
|
||||
QList<TestCard *> temp;
|
||||
for (int i = cards.size(); i; i--)
|
||||
temp.append(cards.takeAt(rnd->getNumber(0, i - 1)));
|
||||
cards = temp;
|
||||
}
|
||||
|
||||
TestCard *PlayerZone::getCard(int id, bool remove, int *position)
|
||||
{
|
||||
if (hasIdAccess()) {
|
||||
QListIterator<TestCard *> CardIterator(cards);
|
||||
int i = 0;
|
||||
while (CardIterator.hasNext()) {
|
||||
TestCard *tmp = CardIterator.next();
|
||||
if (tmp->getId() == id) {
|
||||
if (remove)
|
||||
cards.removeAt(i);
|
||||
if (position)
|
||||
*position = i;
|
||||
return tmp;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return NULL;
|
||||
} else {
|
||||
if (id >= cards.size())
|
||||
return NULL;
|
||||
TestCard *tmp = cards[id];
|
||||
if (remove)
|
||||
cards.removeAt(id);
|
||||
if (position)
|
||||
*position = id;
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerZone::insertCard(TestCard *card, int x, int y)
|
||||
{
|
||||
if (hasCoords()) {
|
||||
card->setCoords(x, y);
|
||||
cards.append(card);
|
||||
} else {
|
||||
card->setCoords(0, 0);
|
||||
cards.insert(x, card);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerZone::clear()
|
||||
{
|
||||
for (int i = 0; i < cards.size(); i++)
|
||||
delete cards.at(i);
|
||||
cards.clear();
|
||||
}
|
||||
55
servatrice/src/playerzone.h
Normal file
55
servatrice/src/playerzone.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef PLAYERZONE_H
|
||||
#define PLAYERZONE_H
|
||||
|
||||
#include <QList>
|
||||
#include "testcard.h"
|
||||
#include "testrandom.h"
|
||||
|
||||
class PlayerZone {
|
||||
private:
|
||||
QString name;
|
||||
bool has_coords;
|
||||
bool is_public; // Contents of the zone are visible for anyone
|
||||
bool id_access; // getCard() finds by id, not by list index
|
||||
// Example: When moving a card from the library to the table,
|
||||
// the card has to be found by list index because the client
|
||||
// does not know the id. But when moving a card from the hand
|
||||
// to the table, the card can be found by id because the client
|
||||
// knows the id and the hand does not need to have a specific order.
|
||||
public:
|
||||
PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _id_access);
|
||||
~PlayerZone();
|
||||
|
||||
TestCard *getCard(int id, bool remove, int *position = NULL);
|
||||
|
||||
bool isPublic() { return is_public; }
|
||||
bool hasCoords() { return has_coords; }
|
||||
bool hasIdAccess() { return id_access; }
|
||||
QString getName() { return name; }
|
||||
|
||||
QList<TestCard *> cards;
|
||||
void insertCard(TestCard *card, int x, int y);
|
||||
void shuffle(TestRandom *rnd);
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif
|
||||
33
servatrice/src/returnmessage.cpp
Normal file
33
servatrice/src/returnmessage.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "returnmessage.h"
|
||||
#include "testserversocket.h"
|
||||
|
||||
void ReturnMessage::setMsgId(unsigned int _msg_id)
|
||||
{
|
||||
msg_id = _msg_id;
|
||||
}
|
||||
|
||||
bool ReturnMessage::send(const QString &args, bool success)
|
||||
{
|
||||
TestServerSocket *s = qobject_cast<TestServerSocket *>(parent());
|
||||
if (!s)
|
||||
return false;
|
||||
s->msg(QString("resp|%1|%2|%3").arg(msg_id)
|
||||
.arg(success ? "ok" : "err")
|
||||
.arg(args));
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ReturnMessage::sendList(const QStringList &args)
|
||||
{
|
||||
TestServerSocket *s = qobject_cast<TestServerSocket *>(parent());
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < args.size(); i++)
|
||||
s->msg(QString("%1|%2|%3").arg(cmd)
|
||||
.arg(msg_id)
|
||||
.arg(args[i]));
|
||||
s->msg(QString("%1|%2|.").arg(cmd).arg(msg_id));
|
||||
|
||||
return true;
|
||||
}
|
||||
21
servatrice/src/returnmessage.h
Normal file
21
servatrice/src/returnmessage.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef RETURNMESSAGE_H
|
||||
#define RETURNMESSAGE_H
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
class ReturnMessage : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
unsigned int msg_id;
|
||||
QString cmd;
|
||||
public:
|
||||
ReturnMessage(QObject *parent = 0) : QObject(parent), msg_id(0) { }
|
||||
unsigned int getMsgId() const { return msg_id; }
|
||||
void setMsgId(unsigned int _msg_id);
|
||||
void setCmd(const QString &_cmd) { cmd = _cmd; }
|
||||
bool send(const QString &args = QString(), bool success = true);
|
||||
bool sendList(const QStringList &args);
|
||||
};
|
||||
|
||||
#endif
|
||||
62
servatrice/src/testcard.cpp
Normal file
62
servatrice/src/testcard.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 "testcard.h"
|
||||
|
||||
TestCard::TestCard(QString _name, int _id, int _coord_x, int _coord_y)
|
||||
: id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), counters(0), tapped(false), attacking(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TestCard::~TestCard()
|
||||
{
|
||||
}
|
||||
|
||||
void TestCard::resetState()
|
||||
{
|
||||
setCoords(0, 0);
|
||||
setCounters(0);
|
||||
setTapped(false);
|
||||
setAttacking(false);
|
||||
setFaceDown(false);
|
||||
setAnnotation("");
|
||||
}
|
||||
|
||||
bool TestCard::setAttribute(const QString &aname, const QString &avalue)
|
||||
{
|
||||
if (!aname.compare("counters")) {
|
||||
bool ok;
|
||||
int tmp_int = avalue.toInt(&ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
setCounters(tmp_int);
|
||||
} else if (!aname.compare("tapped")) {
|
||||
setTapped(!avalue.compare("1"));
|
||||
} else if (!aname.compare("attacking")) {
|
||||
setAttacking(!avalue.compare("1"));
|
||||
} else if (!aname.compare("facedown")) {
|
||||
setFaceDown(!avalue.compare("1"));
|
||||
} else if (!aname.compare("annotation")) {
|
||||
setAnnotation(avalue);
|
||||
} else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
63
servatrice/src/testcard.h
Normal file
63
servatrice/src/testcard.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef TESTCARD_H
|
||||
#define TESTCARD_H
|
||||
|
||||
#include <QString>
|
||||
/**
|
||||
@author Max-Wilhelm Bruker <brukie@laptop>
|
||||
*/
|
||||
class TestCard {
|
||||
private:
|
||||
int id;
|
||||
int coord_x, coord_y;
|
||||
QString name;
|
||||
int counters;
|
||||
bool tapped;
|
||||
bool attacking;
|
||||
bool facedown;
|
||||
QString annotation;
|
||||
public:
|
||||
TestCard(QString _name, int _id, int _coord_x, int _coord_y);
|
||||
~TestCard();
|
||||
|
||||
int getId() { return id; }
|
||||
int getX() { return coord_x; }
|
||||
int getY() { return coord_y; }
|
||||
QString getName() { return name; }
|
||||
int getCounters() { return counters; }
|
||||
bool getTapped() { return tapped; }
|
||||
bool getAttacking() { return attacking; }
|
||||
bool getFaceDown() { return facedown; }
|
||||
QString getAnnotation() { return annotation; }
|
||||
|
||||
void setCoords(int x, int y) { coord_x = x; coord_y = y; }
|
||||
void setName(const QString &_name) { name = _name; }
|
||||
void setCounters(int _counters) { counters = _counters; }
|
||||
void setTapped(bool _tapped) { tapped = _tapped; }
|
||||
void setAttacking(bool _attacking) { attacking = _attacking; }
|
||||
void setFaceDown(bool _facedown) { facedown = _facedown; }
|
||||
void setAnnotation(const QString &_annotation) { annotation = _annotation; }
|
||||
|
||||
void resetState();
|
||||
bool setAttribute(const QString &aname, const QString &avalue);
|
||||
};
|
||||
|
||||
#endif
|
||||
18
servatrice/src/testrandom.cpp
Normal file
18
servatrice/src/testrandom.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "testrandom.h"
|
||||
#include <QThread>
|
||||
|
||||
void TestRandom::init()
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
int seed = QDateTime::currentDateTime().toTime_t();
|
||||
qDebug(QString("%1: qsrand(%2)").arg(thread()->metaObject()->className()).arg(seed).toLatin1());
|
||||
qsrand(seed);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
unsigned int TestRandom::getNumber(unsigned int min, unsigned int max)
|
||||
{
|
||||
int r = qrand();
|
||||
return min + (unsigned int) (((double) (max + 1 - min)) * r / (RAND_MAX + 1.0));
|
||||
}
|
||||
18
servatrice/src/testrandom.h
Normal file
18
servatrice/src/testrandom.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef TESTRANDOM_H
|
||||
#define TESTRANDOM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <stdlib.h>
|
||||
|
||||
class TestRandom : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
bool initialized;
|
||||
public:
|
||||
TestRandom(QObject *parent) : QObject(parent), initialized(false) { }
|
||||
void init();
|
||||
unsigned int getNumber(unsigned int min, unsigned int max);
|
||||
};
|
||||
|
||||
#endif
|
||||
107
servatrice/src/testserver.cpp
Normal file
107
servatrice/src/testserver.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 "testserver.h"
|
||||
|
||||
TestServer::TestServer(QObject *parent)
|
||||
: QTcpServer(parent)
|
||||
{
|
||||
}
|
||||
|
||||
TestServer::~TestServer()
|
||||
{
|
||||
}
|
||||
|
||||
void TestServer::gameCreated(TestServerGame *_game, TestServerSocket *_creator)
|
||||
{
|
||||
games << _game;
|
||||
_creator->moveToThread(_game->thread());
|
||||
_game->addPlayer(_creator);
|
||||
}
|
||||
|
||||
void TestServer::addGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator)
|
||||
{
|
||||
TestServerGameThread *newThread = new TestServerGameThread(name, description, password, maxPlayers, creator);
|
||||
connect(newThread, SIGNAL(gameCreated(TestServerGame *, TestServerSocket *)), this, SLOT(gameCreated(TestServerGame *, TestServerSocket *)));
|
||||
connect(newThread, SIGNAL(finished()), this, SLOT(gameClosed()));
|
||||
newThread->start();
|
||||
}
|
||||
|
||||
void TestServer::incomingConnection(int socketId)
|
||||
{
|
||||
TestServerSocket *socket = new TestServerSocket(this);
|
||||
socket->setSocketDescriptor(socketId);
|
||||
connect(socket, SIGNAL(createGame(const QString, const QString, const QString, const int, TestServerSocket *)), this, SLOT(addGame(const QString, const QString, const QString, const int, TestServerSocket *)));
|
||||
connect(socket, SIGNAL(joinGame(const QString, TestServerSocket *)), this, SLOT(addClientToGame(const QString, TestServerSocket *)));
|
||||
socket->initConnection();
|
||||
}
|
||||
|
||||
TestServerGame *TestServer::getGame(const QString &name)
|
||||
{
|
||||
QListIterator<TestServerGame *> i(games);
|
||||
while (i.hasNext()) {
|
||||
TestServerGame *tmp = i.next();
|
||||
if ((!tmp->name.compare(name, Qt::CaseSensitive)) && !tmp->getGameStarted())
|
||||
return tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QList<TestServerGame *> TestServer::listOpenGames()
|
||||
{
|
||||
QList<TestServerGame *> result;
|
||||
QListIterator<TestServerGame *> i(games);
|
||||
while (i.hasNext()) {
|
||||
TestServerGame *tmp = i.next();
|
||||
tmp->mutex->lock();
|
||||
if ((!tmp->getGameStarted())
|
||||
&& (tmp->getPlayerCount() < tmp->maxPlayers))
|
||||
result.append(tmp);
|
||||
tmp->mutex->unlock();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TestServer::checkGamePassword(const QString &name, const QString &password)
|
||||
{
|
||||
TestServerGame *tmp;
|
||||
if ((tmp = getGame(name))) {
|
||||
QMutexLocker locker(tmp->mutex);
|
||||
if ((!tmp->getGameStarted())
|
||||
&& (!tmp->password.compare(password, Qt::CaseSensitive))
|
||||
&& (tmp->getPlayerCount() < tmp->maxPlayers))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TestServer::addClientToGame(const QString name, TestServerSocket *client)
|
||||
{
|
||||
TestServerGame *tmp = getGame(name);
|
||||
client->moveToThread(tmp->thread());
|
||||
tmp->addPlayer(client);
|
||||
}
|
||||
|
||||
void TestServer::gameClosed()
|
||||
{
|
||||
qDebug("TestServer::gameClosed");
|
||||
TestServerGameThread *t = qobject_cast<TestServerGameThread *>(sender());
|
||||
games.removeAt(games.indexOf(t->getGame()));
|
||||
delete t;
|
||||
}
|
||||
49
servatrice/src/testserver.h
Normal file
49
servatrice/src/testserver.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef TESTSERVER_H
|
||||
#define TESTSERVER_H
|
||||
|
||||
#include <QTcpServer>
|
||||
#include "testservergamethread.h"
|
||||
#include "testservergame.h"
|
||||
|
||||
class TestServerGame;
|
||||
class TestServerSocket;
|
||||
|
||||
class TestServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void addGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator);
|
||||
void addClientToGame(const QString name, TestServerSocket *client);
|
||||
void gameCreated(TestServerGame *_game, TestServerSocket *_creator);
|
||||
void gameClosed();
|
||||
public:
|
||||
TestServer(QObject *parent = 0);
|
||||
~TestServer();
|
||||
bool checkGamePassword(const QString &name, const QString &password);
|
||||
QList<TestServerGame *> listOpenGames();
|
||||
TestServerGame *getGame(const QString &name);
|
||||
private:
|
||||
void incomingConnection(int SocketId);
|
||||
QList<TestServerGame *> games;
|
||||
};
|
||||
|
||||
#endif
|
||||
155
servatrice/src/testservergame.cpp
Normal file
155
servatrice/src/testservergame.cpp
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 "testservergame.h"
|
||||
|
||||
TestServerGame::TestServerGame(QString _name, QString _description, QString _password, int _maxPlayers, QObject *parent)
|
||||
: QObject(parent), name(_name), description(_description), password(_password), maxPlayers(_maxPlayers)
|
||||
{
|
||||
gameStarted = false;
|
||||
mutex = new QMutex(QMutex::Recursive);
|
||||
rnd = NULL;
|
||||
}
|
||||
|
||||
TestServerGame::~TestServerGame()
|
||||
{
|
||||
if (rnd)
|
||||
delete rnd;
|
||||
delete mutex;
|
||||
qDebug("TestServerGame destructor");
|
||||
}
|
||||
|
||||
bool TestServerGame::getGameStarted()
|
||||
{
|
||||
return gameStarted;
|
||||
}
|
||||
|
||||
int TestServerGame::getPlayerCount()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return players.size();
|
||||
}
|
||||
|
||||
QStringList TestServerGame::getPlayerNames()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
QStringList result;
|
||||
QListIterator<TestServerSocket *> i(players);
|
||||
while (i.hasNext()) {
|
||||
TestServerSocket *tmp = i.next();
|
||||
result << QString("%1|%2").arg(tmp->getPlayerId()).arg(tmp->PlayerName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TestServerSocket *TestServerGame::getPlayer(int player_id)
|
||||
{
|
||||
QListIterator<TestServerSocket *> i(players);
|
||||
while (i.hasNext()) {
|
||||
TestServerSocket *tmp = i.next();
|
||||
if (tmp->getPlayerId() == player_id)
|
||||
return tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TestServerGame::msg(const QString &s)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
QListIterator<TestServerSocket *> i(players);
|
||||
while (i.hasNext())
|
||||
i.next()->msg(s);
|
||||
}
|
||||
|
||||
void TestServerGame::broadcastEvent(const QString &cmd, TestServerSocket *player)
|
||||
{
|
||||
if (player)
|
||||
msg(QString("public|%1|%2|%3").arg(player->getPlayerId()).arg(player->PlayerName).arg(cmd));
|
||||
else
|
||||
msg(QString("public|||%1").arg(cmd));
|
||||
}
|
||||
|
||||
void TestServerGame::startGameIfReady()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
if (players.size() < maxPlayers)
|
||||
return;
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
if (players.at(i)->getStatus() != StatusReadyStart)
|
||||
return;
|
||||
|
||||
rnd = new TestRandom(this);
|
||||
rnd->init();
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
players.at(i)->setupZones();
|
||||
|
||||
activePlayer = 0;
|
||||
activePhase = 0;
|
||||
gameStarted = true;
|
||||
broadcastEvent("game_start", NULL);
|
||||
}
|
||||
|
||||
void TestServerGame::addPlayer(TestServerSocket *player)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
int max = -1;
|
||||
QListIterator<TestServerSocket *> i(players);
|
||||
while (i.hasNext()) {
|
||||
int tmp = i.next()->getPlayerId();
|
||||
if (tmp > max)
|
||||
max = tmp;
|
||||
}
|
||||
player->setPlayerId(max + 1);
|
||||
|
||||
player->setGame(this);
|
||||
player->msg(QString("private|||player_id|%1|%2").arg(max + 1).arg(player->PlayerName));
|
||||
broadcastEvent("join", player);
|
||||
|
||||
players << player;
|
||||
|
||||
connect(player, SIGNAL(broadcastEvent(const QString &, TestServerSocket *)), this, SLOT(broadcastEvent(const QString &, TestServerSocket *)));
|
||||
}
|
||||
|
||||
void TestServerGame::removePlayer(TestServerSocket *player)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
players.removeAt(players.indexOf(player));
|
||||
broadcastEvent("leave", player);
|
||||
if (!players.size())
|
||||
thread()->quit();
|
||||
}
|
||||
|
||||
void TestServerGame::setActivePlayer(int _activePlayer)
|
||||
{
|
||||
activePlayer = _activePlayer;
|
||||
broadcastEvent(QString("set_active_player|%1").arg(_activePlayer), NULL);
|
||||
setActivePhase(0);
|
||||
}
|
||||
|
||||
void TestServerGame::setActivePhase(int _activePhase)
|
||||
{
|
||||
activePhase = _activePhase;
|
||||
broadcastEvent(QString("set_active_phase|%1").arg(_activePhase), NULL);
|
||||
}
|
||||
64
servatrice/src/testservergame.h
Normal file
64
servatrice/src/testservergame.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef TESTSERVERGAME_H
|
||||
#define TESTSERVERGAME_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QStringList>
|
||||
#include "testserversocket.h"
|
||||
#include "testrandom.h"
|
||||
|
||||
class TestServerSocket;
|
||||
|
||||
class TestServerGame : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QList<TestServerSocket *> players;
|
||||
bool gameStarted;
|
||||
int activePlayer;
|
||||
int activePhase;
|
||||
public slots:
|
||||
void broadcastEvent(const QString &event, TestServerSocket *player);
|
||||
public:
|
||||
QMutex *mutex;
|
||||
TestRandom *rnd;
|
||||
QString name;
|
||||
QString description;
|
||||
QString password;
|
||||
int maxPlayers;
|
||||
TestServerGame(QString _name, QString _description, QString _password, int _maxPlayers, QObject *parent = 0);
|
||||
~TestServerGame();
|
||||
bool getGameStarted();
|
||||
int getPlayerCount();
|
||||
QStringList getPlayerNames();
|
||||
TestServerSocket *getPlayer(int player_id);
|
||||
void addPlayer(TestServerSocket *player);
|
||||
void removePlayer(TestServerSocket *player);
|
||||
void startGameIfReady();
|
||||
void msg(const QString &s);
|
||||
int getActivePlayer() { return activePlayer; }
|
||||
int getActivePhase() { return activePhase; }
|
||||
void setActivePlayer(int _activePlayer);
|
||||
void setActivePhase(int _activePhase);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
20
servatrice/src/testservergamethread.cpp
Normal file
20
servatrice/src/testservergamethread.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "testservergamethread.h"
|
||||
|
||||
TestServerGameThread::TestServerGameThread(const QString _name, const QString _description, const QString _password, const int _maxPlayers, TestServerSocket *_creator, QObject *parent)
|
||||
: QThread(parent), name(_name), description(_description), password(_password), maxPlayers(_maxPlayers), creator(_creator), game(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TestServerGameThread::~TestServerGameThread()
|
||||
{
|
||||
if (game)
|
||||
delete game;
|
||||
}
|
||||
|
||||
void TestServerGameThread::run()
|
||||
{
|
||||
game = new TestServerGame(name, description, password, maxPlayers);
|
||||
emit gameCreated(game, creator);
|
||||
exec();
|
||||
}
|
||||
30
servatrice/src/testservergamethread.h
Normal file
30
servatrice/src/testservergamethread.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef TESTSERVERGAMETHREAD_H
|
||||
#define TESTSERVERGAMETHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include "testservergame.h"
|
||||
#include "testserversocket.h"
|
||||
|
||||
class TestServerGame;
|
||||
class TestServerSocket;
|
||||
|
||||
class TestServerGameThread : public QThread {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void gameCreated(TestServerGame *_game, TestServerSocket *creator);
|
||||
private:
|
||||
QString name;
|
||||
QString description;
|
||||
QString password;
|
||||
int maxPlayers;
|
||||
TestServerSocket *creator;
|
||||
TestServerGame *game;
|
||||
public:
|
||||
TestServerGameThread(const QString _name, const QString _description, const QString _password, const int _maxPlayers, TestServerSocket *_creator, QObject *parent = 0);
|
||||
~TestServerGameThread();
|
||||
TestServerGame *getGame() { return game; }
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
595
servatrice/src/testserversocket.cpp
Normal file
595
servatrice/src/testserversocket.cpp
Normal file
|
|
@ -0,0 +1,595 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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 <QStringList>
|
||||
#include "testserver.h"
|
||||
#include "testserversocket.h"
|
||||
#include "version.h"
|
||||
|
||||
TestServerSocket::TestServerSocket(TestServer *_server, QObject *parent)
|
||||
: QTcpSocket(parent), server(_server)
|
||||
{
|
||||
remsg = new ReturnMessage(this);
|
||||
connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
|
||||
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
||||
setTextModeEnabled(true);
|
||||
PlayerStatus = StatusNormal;
|
||||
game = 0;
|
||||
}
|
||||
|
||||
TestServerSocket::~TestServerSocket()
|
||||
{
|
||||
qDebug("TestServerSocket destructor");
|
||||
if (game)
|
||||
game->removePlayer(this);
|
||||
}
|
||||
|
||||
void TestServerSocket::setName(const QString &name)
|
||||
{
|
||||
emit broadcastEvent(QString("name|%1|%2").arg(PlayerName).arg(name), this);
|
||||
PlayerName = name;
|
||||
}
|
||||
|
||||
PlayerZone *TestServerSocket::getZone(const QString &name)
|
||||
{
|
||||
QListIterator<PlayerZone *> ZoneIterator(zones);
|
||||
while (ZoneIterator.hasNext()) {
|
||||
PlayerZone *temp = ZoneIterator.next();
|
||||
if (!temp->getName().compare(name))
|
||||
return temp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Counter *TestServerSocket::getCounter(const QString &name)
|
||||
{
|
||||
QListIterator<Counter *> CounterIterator(counters);
|
||||
while (CounterIterator.hasNext()) {
|
||||
Counter *temp = CounterIterator.next();
|
||||
if (!temp->getName().compare(name))
|
||||
return temp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TestServerSocket::setupZones()
|
||||
{
|
||||
// Delete existing zones and counters
|
||||
clearZones();
|
||||
|
||||
// This may need to be customized according to the game rules.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// Create zones
|
||||
PlayerZone *deck = new PlayerZone("deck", false, false, false);
|
||||
zones << deck;
|
||||
PlayerZone *sb = new PlayerZone("sb", false, false, false);
|
||||
zones << sb;
|
||||
zones << new PlayerZone("table", true, true, true);
|
||||
zones << new PlayerZone("hand", false, false, true);
|
||||
zones << new PlayerZone("grave", false, true, true);
|
||||
zones << new PlayerZone("rfg", false, true, true);
|
||||
|
||||
// Create life counter
|
||||
Counter *life = new Counter("life", 20);
|
||||
counters << life;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// Assign card ids and create deck from decklist
|
||||
QListIterator<QString> DeckIterator(DeckList);
|
||||
int i = 0;
|
||||
while (DeckIterator.hasNext())
|
||||
deck->cards.append(new TestCard(DeckIterator.next(), i++, 0, 0));
|
||||
deck->shuffle(game->rnd);
|
||||
|
||||
QListIterator<QString> SBIterator(SideboardList);
|
||||
while (SBIterator.hasNext())
|
||||
sb->cards.append(new TestCard(SBIterator.next(), i++, 0, 0));
|
||||
|
||||
nextCardId = i;
|
||||
|
||||
PlayerStatus = StatusPlaying;
|
||||
broadcastEvent(QString("setup_zones|%1|%2|%3").arg(getCounter("life")->getCount())
|
||||
.arg(deck->cards.size())
|
||||
.arg(getZone("sb")->cards.size()), this);
|
||||
}
|
||||
|
||||
void TestServerSocket::clearZones()
|
||||
{
|
||||
for (int i = 0; i < zones.size(); i++)
|
||||
delete zones.at(i);
|
||||
zones.clear();
|
||||
|
||||
for (int i = 0; i < counters.size(); i++)
|
||||
delete counters.at(i);
|
||||
counters.clear();
|
||||
}
|
||||
|
||||
void TestServerSocket::leaveGame()
|
||||
{
|
||||
if (!game)
|
||||
return;
|
||||
game->removePlayer(this);
|
||||
game = 0;
|
||||
PlayerStatus = StatusNormal;
|
||||
clearZones();
|
||||
moveToThread(server->thread());
|
||||
}
|
||||
|
||||
void TestServerSocket::readClient()
|
||||
{
|
||||
QTextStream *stream = new QTextStream(this);
|
||||
stream->setCodec("UTF-8");
|
||||
QStringList lines;
|
||||
|
||||
// Before parsing, everything has to be buffered so that the stream
|
||||
// can be deleted in order to avoid problems when moving the object
|
||||
// to another thread while this function is still running.
|
||||
for (;;) {
|
||||
QString line = stream->readLine();
|
||||
if (line.isNull())
|
||||
break;
|
||||
lines << line;
|
||||
}
|
||||
delete stream;
|
||||
|
||||
QStringListIterator i(lines);
|
||||
while (i.hasNext()) {
|
||||
QString line = i.next();
|
||||
|
||||
qDebug(QString("<<< %1").arg(line).toLatin1());
|
||||
switch (PlayerStatus) {
|
||||
case StatusNormal:
|
||||
case StatusReadyStart:
|
||||
case StatusPlaying:
|
||||
parseCommand(line);
|
||||
break;
|
||||
case StatusSubmitDeck:
|
||||
QString card = line;
|
||||
if (!card.compare(".")) {
|
||||
PlayerStatus = StatusNormal;
|
||||
remsg->send();
|
||||
} else if (card.startsWith("SB:"))
|
||||
SideboardList << card.mid(3);
|
||||
else
|
||||
DeckList << card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TestServerSocket::parseCommand(QString line)
|
||||
{
|
||||
QStringList params = line.split("|");
|
||||
|
||||
// Extract message id
|
||||
bool conv_ok;
|
||||
int msgId = params.takeFirst().toInt(&conv_ok);
|
||||
if (!conv_ok) {
|
||||
remsg->setMsgId(0);
|
||||
return remsg->send("syntax", false);
|
||||
}
|
||||
remsg->setMsgId(msgId);
|
||||
|
||||
if (params.empty()) {
|
||||
remsg->setMsgId(0);
|
||||
return remsg->send("syntax", false);
|
||||
}
|
||||
|
||||
// Extract command
|
||||
QString cmd = params.takeFirst();
|
||||
remsg->setCmd(cmd);
|
||||
|
||||
// parse command
|
||||
|
||||
if (!cmd.compare("list_games", Qt::CaseInsensitive)) {
|
||||
remsg->send();
|
||||
QList<TestServerGame *> gameList = server->listOpenGames();
|
||||
QListIterator<TestServerGame *> gameListIterator(gameList);
|
||||
QStringList result;
|
||||
while (gameListIterator.hasNext()) {
|
||||
TestServerGame *tmp = gameListIterator.next();
|
||||
tmp->mutex->lock();
|
||||
result << QString("%1|%2|%3|%4|%5").arg(tmp->name)
|
||||
.arg(tmp->description)
|
||||
.arg(tmp->password == "" ? 0 : 1)
|
||||
.arg(tmp->getPlayerCount())
|
||||
.arg(tmp->maxPlayers);
|
||||
tmp->mutex->unlock();
|
||||
}
|
||||
remsg->sendList(result);
|
||||
} else if (!cmd.compare("create_game", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 4)
|
||||
return remsg->send("syntax", false);
|
||||
QString name = params[0];
|
||||
QString description = params[1];
|
||||
QString password = params[2];
|
||||
int maxPlayers = params[3].toInt();
|
||||
if (server->getGame(name))
|
||||
return remsg->send("name_not_found", false);
|
||||
remsg->send();
|
||||
leaveGame();
|
||||
|
||||
emit createGame(name, description, password, maxPlayers, this);
|
||||
} else if (!cmd.compare("join_game", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 2)
|
||||
return remsg->send("syntax", false);
|
||||
QString name = params[0];
|
||||
QString password = params[1];
|
||||
if (!server->checkGamePassword(name, password))
|
||||
return remsg->send("wrong_password", false);
|
||||
remsg->send();
|
||||
leaveGame();
|
||||
|
||||
emit joinGame(name, this);
|
||||
} else if (!cmd.compare("leave_game", Qt::CaseInsensitive)) {
|
||||
remsg->send();
|
||||
leaveGame();
|
||||
} else if (!cmd.compare("set_name", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
remsg->send();
|
||||
setName(params[0]);
|
||||
} else if (!cmd.compare("list_players", Qt::CaseInsensitive)) {
|
||||
if (!game)
|
||||
return remsg->send("game_state", false);
|
||||
|
||||
remsg->send();
|
||||
remsg->sendList(game->getPlayerNames());
|
||||
} else if (!cmd.compare("say", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
remsg->send();
|
||||
emit broadcastEvent(QString("say|%1").arg(params[0]), this);
|
||||
} else if (!cmd.compare("submit_deck", Qt::CaseInsensitive)) {
|
||||
PlayerStatus = StatusSubmitDeck;
|
||||
DeckList.clear();
|
||||
SideboardList.clear();
|
||||
} else if (!cmd.compare("shuffle", Qt::CaseInsensitive)) {
|
||||
if (!game)
|
||||
return remsg->send("game_state", false);
|
||||
if (!game->getGameStarted())
|
||||
return remsg->send("game_state", false);
|
||||
getZone("deck")->shuffle(game->rnd);
|
||||
remsg->send();
|
||||
emit broadcastEvent("shuffle", this);
|
||||
} else if (!cmd.compare("ready_start", Qt::CaseInsensitive)) {
|
||||
if (!game)
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
PlayerStatus = StatusReadyStart;
|
||||
emit broadcastEvent(QString("ready_start"), this);
|
||||
game->startGameIfReady();
|
||||
} else if (!cmd.compare("draw_cards", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int number = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
PlayerZone *deck = getZone("deck");
|
||||
PlayerZone *hand = getZone("hand");
|
||||
|
||||
if (deck->cards.size() < number)
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
|
||||
for (int i = 0; i < number; ++i) {
|
||||
TestCard *card = deck->cards.first();
|
||||
deck->cards.removeFirst();
|
||||
hand->cards.append(card);
|
||||
msg(QString("private|||draw|%1|%2").arg(card->getId()).arg(card->getName()));
|
||||
}
|
||||
|
||||
emit broadcastEvent(QString("draw|%1").arg(number), this);
|
||||
} else if (!cmd.compare("move_card", Qt::CaseInsensitive)) {
|
||||
// ID Karte, Startzone, Zielzone, Koordinaten X, Y
|
||||
if (params.size() != 5)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int cardid = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
PlayerZone *startzone = getZone(params[1]);
|
||||
PlayerZone *targetzone = getZone(params[2]);
|
||||
if ((!startzone) || (!targetzone))
|
||||
return remsg->send("game_state", false);
|
||||
|
||||
int position = -1;
|
||||
TestCard *card = startzone->getCard(cardid, true, &position);
|
||||
if (!card)
|
||||
return remsg->send("game_state", false);
|
||||
int x = params[3].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
int y = 0;
|
||||
if (targetzone->hasCoords()) {
|
||||
y = params[4].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
}
|
||||
targetzone->insertCard(card, x, y);
|
||||
remsg->send();
|
||||
msg(QString("private|||move_card|%1|%2|%3|%4|%5|%6|%7").arg(card->getId())
|
||||
.arg(card->getName())
|
||||
.arg(startzone->getName())
|
||||
.arg(position)
|
||||
.arg(targetzone->getName())
|
||||
.arg(x)
|
||||
.arg(y));
|
||||
// Was ist mit Facedown-Karten?
|
||||
if ((startzone->isPublic()) || (targetzone->isPublic()))
|
||||
emit broadcastEvent(QString("move_card|%1|%2|%3|%4|%5|%6|%7").arg(card->getId())
|
||||
.arg(card->getName())
|
||||
.arg(startzone->getName())
|
||||
.arg(position)
|
||||
.arg(targetzone->getName())
|
||||
.arg(x)
|
||||
.arg(y), this);
|
||||
else
|
||||
emit broadcastEvent(QString("move_card|||%1|%2|%3|%4|%5").arg(startzone->getName())
|
||||
.arg(position)
|
||||
.arg(targetzone->getName())
|
||||
.arg(x)
|
||||
.arg(y), this);
|
||||
} else if (!cmd.compare("create_token", Qt::CaseInsensitive)) {
|
||||
// zone, cardname, powtough, x, y
|
||||
// powtough wird erst mal ignoriert
|
||||
if (params.size() != 5)
|
||||
return remsg->send("syntax", false);
|
||||
PlayerZone *zone = getZone(params[0]);
|
||||
if (!zone)
|
||||
return remsg->send("game_state", false);
|
||||
QString cardname = params[1];
|
||||
int x = params[3].toInt();
|
||||
int y = params[4].toInt();
|
||||
int cardid = nextCardId++;
|
||||
QString powtough = params[2];
|
||||
|
||||
remsg->send();
|
||||
TestCard *card = new TestCard(cardname, cardid, x, y);
|
||||
zone->insertCard(card, x, y);
|
||||
emit broadcastEvent(QString("create_token|%1|%2|%3|%4|%5|%6").arg(zone->getName())
|
||||
.arg(cardid)
|
||||
.arg(cardname)
|
||||
.arg(powtough)
|
||||
.arg(x)
|
||||
.arg(y), this);
|
||||
} else if (!cmd.compare("set_card_attr", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 4)
|
||||
return remsg->send("syntax", false);
|
||||
// zone, card id, attr name, attr value
|
||||
// card id = -1 => affects all cards in the specified zone
|
||||
PlayerZone *zone = getZone(params[0]);
|
||||
if (!zone)
|
||||
return remsg->send("game_state", false);
|
||||
bool ok;
|
||||
int cardid = params[1].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
|
||||
if (cardid == -1) {
|
||||
QListIterator<TestCard *> CardIterator(zone->cards);
|
||||
while (CardIterator.hasNext())
|
||||
if (!CardIterator.next()->setAttribute(params[2], params[3]))
|
||||
return remsg->send("syntax", false);
|
||||
} else {
|
||||
TestCard *card = zone->getCard(cardid, false);
|
||||
if (!card)
|
||||
return remsg->send("game_state", false);
|
||||
if (!card->setAttribute(params[2], params[3]))
|
||||
return remsg->send("syntax", false);
|
||||
}
|
||||
remsg->send();
|
||||
emit broadcastEvent(QString("set_card_attr|%1|%2|%3|%4").arg(zone->getName()).arg(cardid).arg(params[2]).arg(params[3]), this);
|
||||
} else if (!cmd.compare("inc_counter", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 2)
|
||||
return remsg->send("syntax", false);
|
||||
Counter *c = getCounter(params[0]);
|
||||
if (!c)
|
||||
return remsg->send("game_state", false);
|
||||
bool ok;
|
||||
int delta = params[1].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
remsg->send();
|
||||
c->setCount(c->getCount() + delta);
|
||||
emit broadcastEvent(QString("set_counter|%1|%2").arg(params[0]).arg(c->getCount()), this);
|
||||
} else if (!cmd.compare("set_counter", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 2)
|
||||
return remsg->send("syntax", false);
|
||||
Counter *c = getCounter(params[0]);
|
||||
bool ok;
|
||||
int count = params[1].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
if (!c) {
|
||||
c = new Counter(params[0], count);
|
||||
counters << c;
|
||||
} else
|
||||
c->setCount(count);
|
||||
remsg->send();
|
||||
emit broadcastEvent(QString("set_counter|%1|%2").arg(params[0]).arg(count), this);
|
||||
} else if (!cmd.compare("del_counter", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
Counter *c = getCounter(params[0]);
|
||||
if (!c)
|
||||
return remsg->send("game_state", false);
|
||||
delete c;
|
||||
counters.removeAt(counters.indexOf(c));
|
||||
remsg->send();
|
||||
emit broadcastEvent(QString("del_counter|%1").arg(params[0]), this);
|
||||
} else if (!cmd.compare("list_counters", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int player_id = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
TestServerSocket *player = game->getPlayer(player_id);
|
||||
if (!player)
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
remsg->sendList(player->listCounters());
|
||||
} else if (!cmd.compare("list_zones", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int player_id = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
TestServerSocket *player = game->getPlayer(player_id);
|
||||
if (!player)
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
remsg->sendList(player->listZones());
|
||||
} else if (!cmd.compare("dump_zone", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 3)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int player_id = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
int number_cards = params[2].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
TestServerSocket *player = game->getPlayer(player_id);
|
||||
if (!player)
|
||||
return remsg->send("game_state", false);
|
||||
PlayerZone *zone = player->getZone(params[1]);
|
||||
if (!zone)
|
||||
return remsg->send("game_state", false);
|
||||
if (!(zone->isPublic() || (player_id == PlayerId)))
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
QListIterator<TestCard *> card_iterator(zone->cards);
|
||||
QStringList result;
|
||||
for (int i = 0; card_iterator.hasNext() && (i < number_cards || number_cards == 0); i++) {
|
||||
TestCard *tmp = card_iterator.next();
|
||||
// XXX Face down cards
|
||||
if (zone->hasIdAccess())
|
||||
result << QString("%1|%2|%3|%4|%5|%6|%7|%8").arg(tmp->getId())
|
||||
.arg(tmp->getName())
|
||||
.arg(tmp->getX())
|
||||
.arg(tmp->getY())
|
||||
.arg(tmp->getCounters())
|
||||
.arg(tmp->getTapped())
|
||||
.arg(tmp->getAttacking())
|
||||
.arg(tmp->getAnnotation());
|
||||
else
|
||||
result << QString("%1|%2||||||").arg(i).arg(tmp->getName());
|
||||
}
|
||||
remsg->sendList(result);
|
||||
emit broadcastEvent(QString("dump_zone|%1|%2|%3").arg(player_id).arg(zone->getName()).arg(number_cards), this);
|
||||
} else if (!cmd.compare("roll_dice", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int sides = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
remsg->send();
|
||||
emit broadcastEvent(QString("roll_dice|%1|%2").arg(sides).arg(game->rnd->getNumber(1, sides)), this);
|
||||
} else if (!cmd.compare("set_active_player", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int active_player = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
if (!game->getPlayer(active_player))
|
||||
return remsg->send("game_state", false);
|
||||
remsg->send();
|
||||
game->setActivePlayer(active_player);
|
||||
} else if (!cmd.compare("set_active_phase", Qt::CaseInsensitive)) {
|
||||
if (params.size() != 1)
|
||||
return remsg->send("syntax", false);
|
||||
bool ok;
|
||||
int active_phase = params[0].toInt(&ok);
|
||||
if (!ok)
|
||||
return remsg->send("syntax", false);
|
||||
// XXX Überprüfung, ob die Phase existiert...
|
||||
remsg->send();
|
||||
game->setActivePhase(active_phase);
|
||||
} else
|
||||
return remsg->send("syntax", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerStatusEnum TestServerSocket::getStatus()
|
||||
{
|
||||
return PlayerStatus;
|
||||
}
|
||||
|
||||
void TestServerSocket::setStatus(PlayerStatusEnum status)
|
||||
{
|
||||
PlayerStatus = status;
|
||||
}
|
||||
|
||||
void TestServerSocket::setGame(TestServerGame *g)
|
||||
{
|
||||
game = g;
|
||||
}
|
||||
|
||||
QStringList TestServerSocket::listCounters()
|
||||
{
|
||||
QStringList counter_list;
|
||||
QListIterator<Counter *> i(counters);
|
||||
while (i.hasNext()) {
|
||||
Counter *tmp = i.next();
|
||||
counter_list << QString("%1|%2").arg(tmp->getName()).arg(tmp->getCount());
|
||||
}
|
||||
return counter_list;
|
||||
}
|
||||
|
||||
QStringList TestServerSocket::listZones()
|
||||
{
|
||||
QStringList zone_list;
|
||||
QListIterator<PlayerZone *> i(zones);
|
||||
while (i.hasNext()) {
|
||||
PlayerZone *tmp = i.next();
|
||||
zone_list << QString("%1|%2|%3|%4").arg(tmp->getName()).arg(tmp->isPublic()).arg(tmp->hasCoords()).arg(tmp->cards.size());
|
||||
}
|
||||
return zone_list;
|
||||
}
|
||||
|
||||
void TestServerSocket::msg(const QString &s)
|
||||
{
|
||||
qDebug(QString(">>> %1").arg(s).toLatin1());
|
||||
QTextStream stream(this);
|
||||
stream.setCodec("UTF-8");
|
||||
stream << s << endl;
|
||||
stream.flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
void TestServerSocket::initConnection()
|
||||
{
|
||||
msg(QString("welcome||%1").arg(VERSION_STRING));
|
||||
msg("welcome||.");
|
||||
}
|
||||
|
||||
void TestServerSocket::catchSocketError(QAbstractSocket::SocketError socketError)
|
||||
{
|
||||
qDebug(QString("socket error: %1").arg(socketError).toLatin1());
|
||||
deleteLater();
|
||||
}
|
||||
81
servatrice/src/testserversocket.h
Normal file
81
servatrice/src/testserversocket.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef TESTSERVERSOCKET_H
|
||||
#define TESTSERVERSOCKET_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include "testserver.h"
|
||||
#include "testservergame.h"
|
||||
#include "playerzone.h"
|
||||
#include "returnmessage.h"
|
||||
#include "counter.h"
|
||||
|
||||
class TestServer;
|
||||
class TestServerGame;
|
||||
class PlayerZone;
|
||||
|
||||
enum PlayerStatusEnum { StatusNormal, StatusSubmitDeck, StatusReadyStart, StatusPlaying };
|
||||
|
||||
class TestServerSocket : public QTcpSocket
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void readClient();
|
||||
void catchSocketError(QAbstractSocket::SocketError socketError);
|
||||
signals:
|
||||
void createGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator);
|
||||
void joinGame(const QString name, TestServerSocket *player);
|
||||
void commandReceived(QString cmd, TestServerSocket *player);
|
||||
void broadcastEvent(const QString &event, TestServerSocket *player);
|
||||
void startGameIfReady();
|
||||
private:
|
||||
TestServer *server;
|
||||
TestServerGame *game;
|
||||
QList<QString> DeckList;
|
||||
QList<QString> SideboardList;
|
||||
QList<PlayerZone *> zones;
|
||||
QList<Counter *> counters;
|
||||
int PlayerId;
|
||||
int nextCardId;
|
||||
PlayerZone *getZone(const QString &name);
|
||||
Counter *getCounter(const QString &name);
|
||||
void setName(const QString &name);
|
||||
void clearZones();
|
||||
void leaveGame();
|
||||
bool parseCommand(QString line);
|
||||
PlayerStatusEnum PlayerStatus;
|
||||
ReturnMessage *remsg;
|
||||
public:
|
||||
QString PlayerName;
|
||||
TestServerSocket(TestServer *_server, QObject *parent = 0);
|
||||
~TestServerSocket();
|
||||
void msg(const QString &s);
|
||||
void setGame(TestServerGame *g);
|
||||
PlayerStatusEnum getStatus();
|
||||
void setStatus(PlayerStatusEnum status);
|
||||
void initConnection();
|
||||
int getPlayerId() { return PlayerId; }
|
||||
void setPlayerId(int _id) { PlayerId = _id; }
|
||||
QStringList listCounters();
|
||||
QStringList listZones();
|
||||
void setupZones();
|
||||
};
|
||||
|
||||
#endif
|
||||
21
servatrice/src/version.h
Normal file
21
servatrice/src/version.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@laptop *
|
||||
* *
|
||||
* 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; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
const char *VERSION_STRING = "Testserver 0.20090304";
|
||||
Loading…
Add table
Add a link
Reference in a new issue