Removing console client. It no longer works, and won't be maintained any more.
This commit is contained in:
@@ -1,661 +0,0 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
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
|
||||
them 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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
@@ -1,209 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using pokerth_lib;
|
||||
|
||||
namespace pokerth_console
|
||||
{
|
||||
class ConsoleCallback : pokerth_lib.ICallback
|
||||
{
|
||||
public void InitDone()
|
||||
{
|
||||
Console.WriteLine("Connection established.");
|
||||
Console.WriteLine("Retrieving list of games...");
|
||||
}
|
||||
|
||||
public void JoinedGame(string name)
|
||||
{
|
||||
Console.WriteLine("Successfully joined game \"{0}\".", name);
|
||||
}
|
||||
|
||||
public void GameStarted(List<string> players)
|
||||
{
|
||||
string outPlayers = "";
|
||||
foreach (string s in players)
|
||||
{
|
||||
if (outPlayers.Length != 0)
|
||||
outPlayers += ", ";
|
||||
outPlayers += s;
|
||||
}
|
||||
Console.WriteLine("Game was started. Players: {0}.", outPlayers);
|
||||
}
|
||||
|
||||
public void HandStarted(int[] cards)
|
||||
{
|
||||
Console.WriteLine("\nNew hand. Your cards: {0}, {1}.",
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]));
|
||||
}
|
||||
|
||||
public void SmallBlind(string name, uint blind)
|
||||
{
|
||||
Console.WriteLine("{0} posts small blind (${1}).", name, blind);
|
||||
}
|
||||
|
||||
public void BigBlind(string name, uint blind)
|
||||
{
|
||||
Console.WriteLine("{0} posts big blind (${1}).", name, blind);
|
||||
}
|
||||
|
||||
public void MyTurn(Hand.State state, uint highestSet, uint minimumRaise, uint money)
|
||||
{
|
||||
Console.WriteLine("\n--> {0}: Your turn. Highest set: ${1}. Minimum raise: ${2}. Cash: ${3}.",
|
||||
Log.StateToString(state), highestSet, minimumRaise, money);
|
||||
Console.WriteLine("Enter: (f)old, (c)heck, ca(l)l, (b)et<num>, (r)aise<num>, (a)ll in");
|
||||
}
|
||||
|
||||
public void PlayersTurn(Hand.State state, string player)
|
||||
{
|
||||
Console.WriteLine("\n{0}: {1}'s turn.",
|
||||
Log.StateToString(state),
|
||||
player);
|
||||
}
|
||||
|
||||
public void ActionDone(string name, Hand.Action action, uint curBet, uint money, List<string> nonFoldPlayers)
|
||||
{
|
||||
Console.WriteLine("{0} {1}. Cash: ${2}.", name, Log.ActionToString(action, curBet), money);
|
||||
if (action == Hand.Action.Fold)
|
||||
{
|
||||
string outPlayers = "";
|
||||
foreach (string s in nonFoldPlayers)
|
||||
{
|
||||
if (outPlayers.Length != 0)
|
||||
outPlayers += ", ";
|
||||
outPlayers += s;
|
||||
}
|
||||
Console.WriteLine("Remaining players: {0}", outPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActionRejected()
|
||||
{
|
||||
Console.WriteLine("Your action was rejected by the server.");
|
||||
}
|
||||
|
||||
public void ShowPot(uint pot)
|
||||
{
|
||||
Console.WriteLine("\nPot is now ${0}.", pot);
|
||||
}
|
||||
|
||||
public void ShowFlopCards(int[] cards)
|
||||
{
|
||||
Console.WriteLine("--- Flop --- [{0}, {1}, {2}]",
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]),
|
||||
Log.CardToString(cards[2]));
|
||||
}
|
||||
|
||||
public void ShowTurnCards(int[] cards)
|
||||
{
|
||||
Console.WriteLine("--- Turn --- [{0}, {1}, {2}, {3}]",
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]),
|
||||
Log.CardToString(cards[2]),
|
||||
Log.CardToString(cards[3]));
|
||||
}
|
||||
|
||||
public void ShowRiverCards(int[] cards)
|
||||
{
|
||||
Console.WriteLine("--- River --- [{0}, {1}, {2}, {3}, {4}]",
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]),
|
||||
Log.CardToString(cards[2]),
|
||||
Log.CardToString(cards[3]),
|
||||
Log.CardToString(cards[4]));
|
||||
}
|
||||
|
||||
public void AllInState()
|
||||
{
|
||||
Console.WriteLine(); // simply print a newline
|
||||
}
|
||||
|
||||
public void ShowCards(string name, int[] cards)
|
||||
{
|
||||
Console.WriteLine("{0} shows [{1}, {2}].",
|
||||
name,
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]));
|
||||
}
|
||||
|
||||
public void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn)
|
||||
{
|
||||
Console.WriteLine("{0} {1} [{2}, {3}] - {4}.",
|
||||
name,
|
||||
allIn ? "has" : "shows",
|
||||
Log.CardToString(cards[0]),
|
||||
Log.CardToString(cards[1]),
|
||||
Log.CardsValueToString(cardsValue));
|
||||
}
|
||||
|
||||
public void HandResult()
|
||||
{
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
public void PlayerWinsHand(string name, uint moneyWon)
|
||||
{
|
||||
Console.WriteLine("{0} wins ${1}.", name, moneyWon);
|
||||
}
|
||||
|
||||
public void PlayerWinsGame(string name)
|
||||
{
|
||||
Console.WriteLine("\n{0} wins the game.", name);
|
||||
}
|
||||
|
||||
public void RemovedFromGame()
|
||||
{
|
||||
Console.WriteLine("You have left the game.");
|
||||
System.Environment.Exit(1);
|
||||
}
|
||||
|
||||
public void ChatText(string name, string message)
|
||||
{
|
||||
Console.WriteLine("{0}: {1}",
|
||||
name,
|
||||
message);
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
Console.WriteLine("Error: " + message);
|
||||
Console.WriteLine("Hint: Try using a different nickname.");
|
||||
System.Environment.Exit(1);
|
||||
}
|
||||
|
||||
public void AvatarBegin(uint id, uint fileSize, GameInfo.AvatarFileType type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AvatarData(uint id, byte[] block)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AvatarEnd(uint id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Net.Sockets;
|
||||
using pokerth_lib;
|
||||
|
||||
namespace pokerth_console
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void ChooseOpenGame(Client client, PokerTHData data)
|
||||
{
|
||||
string input;
|
||||
bool joined = false;
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
Console.WriteLine("Open Games:");
|
||||
Console.Write(data.GameList.GetOpenGamesString());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Enter game id (or press enter to refresh)");
|
||||
input = Console.ReadLine();
|
||||
} while (input == "" || !Char.IsDigit(input[0]));
|
||||
uint gameId = Convert.ToUInt32(input);
|
||||
string password = "";
|
||||
if (data.GameList.HasGame(gameId)
|
||||
&& data.GameList.GetGameInfo(gameId).PasswordProtected)
|
||||
{
|
||||
Console.WriteLine("Enter game password:");
|
||||
password = Console.ReadLine();
|
||||
}
|
||||
Console.WriteLine("Joining game...");
|
||||
client.JoinGame(gameId, password);
|
||||
// Hack this, because Mono does not support WaitOne(...).
|
||||
DateTime cur = DateTime.Now;
|
||||
while (!client.HasJoinedGame())
|
||||
{
|
||||
Thread.Sleep(15);
|
||||
if (DateTime.Now.Subtract(cur).Seconds > 5)
|
||||
break;
|
||||
}
|
||||
if (client.HasJoinedGame())
|
||||
joined = true;
|
||||
else
|
||||
Console.WriteLine("Could not join game.");
|
||||
} while (!joined);
|
||||
Console.WriteLine("Waiting for admin to start the game...");
|
||||
}
|
||||
|
||||
static void GameLoop(Client client, PokerTHData data)
|
||||
{
|
||||
string input;
|
||||
do
|
||||
{
|
||||
while (Console.KeyAvailable)
|
||||
Console.ReadKey();
|
||||
input = Console.ReadLine();
|
||||
if (input.Length > 0)
|
||||
{
|
||||
Hand.Action action = Hand.Action.None;
|
||||
uint bet = 0;
|
||||
try
|
||||
{
|
||||
switch (input[0])
|
||||
{
|
||||
case 'f':
|
||||
action = Hand.Action.Fold;
|
||||
break;
|
||||
case 'c':
|
||||
action = Hand.Action.Check;
|
||||
break;
|
||||
case 'l':
|
||||
action = Hand.Action.Call;
|
||||
break;
|
||||
case 'b':
|
||||
action = Hand.Action.Bet;
|
||||
bet = Convert.ToUInt32(input.Substring(1));
|
||||
break;
|
||||
case 'r':
|
||||
action = Hand.Action.Raise;
|
||||
bet = Convert.ToUInt32(input.Substring(1));
|
||||
break;
|
||||
case 'a':
|
||||
action = Hand.Action.AllIn;
|
||||
break;
|
||||
}
|
||||
if (action != Hand.Action.None)
|
||||
client.MyAction(action, bet);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
}
|
||||
}
|
||||
} while (data.JoinedGame);
|
||||
}
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("pokerth_console V0.1.2 - Copyright (C) 2008 by Lothar May");
|
||||
Console.WriteLine("See COPYING.txt for license terms.");
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Enter your nickname:");
|
||||
string name = Console.ReadLine();
|
||||
Console.WriteLine("Connecting to server...");
|
||||
Settings settings = new Settings();
|
||||
// Parse command line options.
|
||||
if (args.Length > 0)
|
||||
settings.ServerSettings.Server = args[0];
|
||||
PokerTHData data = new PokerTHData(name);
|
||||
ConsoleCallback callback = new ConsoleCallback();
|
||||
Client client = new Client(settings, data, callback);
|
||||
try
|
||||
{
|
||||
client.Connect();
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
Console.WriteLine("Unable to connect to server.");
|
||||
return 1;
|
||||
}
|
||||
client.Start();
|
||||
Thread.Sleep(2000);
|
||||
ChooseOpenGame(client, data);
|
||||
GameLoop(client, data);
|
||||
client.SetTerminateFlag();
|
||||
client.WaitTermination();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public abstract class BasicThread
|
||||
{
|
||||
public BasicThread()
|
||||
{
|
||||
m_thread = new Thread(ThreadProc);
|
||||
m_terminateFlag = false;
|
||||
m_terminateFlagMutex = new System.Object();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
m_thread.Start(this);
|
||||
}
|
||||
|
||||
protected static void ThreadProc(object obj)
|
||||
{
|
||||
BasicThread me = (BasicThread)obj;
|
||||
me.Main();
|
||||
}
|
||||
|
||||
protected abstract void Main();
|
||||
|
||||
public void WaitTermination()
|
||||
{
|
||||
m_thread.Join();
|
||||
}
|
||||
|
||||
public void SetTerminateFlag()
|
||||
{
|
||||
lock (m_terminateFlagMutex)
|
||||
{
|
||||
m_terminateFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsTerminateFlagSet()
|
||||
{
|
||||
lock (m_terminateFlagMutex)
|
||||
{
|
||||
return m_terminateFlag;
|
||||
}
|
||||
}
|
||||
|
||||
private Thread m_thread;
|
||||
private bool m_terminateFlag;
|
||||
private Object m_terminateFlagMutex;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class GameInfo : IdObject
|
||||
{
|
||||
public enum AvatarFileType
|
||||
{
|
||||
PNG,
|
||||
GIF,
|
||||
JPG,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
public enum Mode
|
||||
{
|
||||
Created = 1,
|
||||
Started,
|
||||
Closed
|
||||
}
|
||||
|
||||
public GameInfo(uint id, string name, Mode mode, List<uint> playerSlots, uint startMoney, bool passwordProtected)
|
||||
: base(id, name)
|
||||
{
|
||||
m_mutex = new Object();
|
||||
m_mode = mode;
|
||||
m_playerSlots = playerSlots;
|
||||
m_startMoney = startMoney;
|
||||
m_passwordProtected = passwordProtected;
|
||||
}
|
||||
|
||||
public List<uint> PlayerSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_playerSlots)
|
||||
{
|
||||
// returns a copy(!)
|
||||
return new List<uint>(m_playerSlots);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_playerSlots)
|
||||
{
|
||||
m_playerSlots = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mode CurrentMode
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_mode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint StartMoney
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_startMoney;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool PasswordProtected
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_passwordProtected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object m_mutex;
|
||||
private Mode m_mode;
|
||||
private List<uint> m_playerSlots;
|
||||
readonly private uint m_startMoney;
|
||||
bool m_passwordProtected;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class GameInfoList
|
||||
{
|
||||
public GameInfoList()
|
||||
{
|
||||
m_list = new Dictionary<uint, GameInfo>();
|
||||
}
|
||||
|
||||
public void AddGameInfo(GameInfo info)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
if (m_list.ContainsKey(info.Id))
|
||||
m_list[info.Id] = info;
|
||||
else
|
||||
m_list.Add(info.Id, info);
|
||||
}
|
||||
}
|
||||
|
||||
public GameInfo GetGameInfo(uint id)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
return m_list[id];
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasGame(uint id)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
return m_list.ContainsKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGameInfo(uint id, GameInfo info)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
m_list[id] = info;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveGameInfo(uint id)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
m_list.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetOpenGamesString()
|
||||
{
|
||||
string outString = "";
|
||||
lock (m_list)
|
||||
{
|
||||
foreach (KeyValuePair<uint, GameInfo> i in m_list)
|
||||
{
|
||||
if (i.Value.CurrentMode == GameInfo.Mode.Created)
|
||||
{
|
||||
outString += i.Key;
|
||||
outString += " ";
|
||||
outString += i.Value.Name;
|
||||
outString += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
return outString;
|
||||
}
|
||||
|
||||
private Dictionary<uint, GameInfo> m_list;
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class Hand
|
||||
{
|
||||
public const int MaxPlayers = 7;
|
||||
|
||||
public enum State
|
||||
{
|
||||
Preflop = 0,
|
||||
Flop,
|
||||
Turn,
|
||||
River
|
||||
}
|
||||
|
||||
public enum Action
|
||||
{
|
||||
None = 0,
|
||||
Fold,
|
||||
Check,
|
||||
Call,
|
||||
Bet,
|
||||
Raise,
|
||||
AllIn
|
||||
}
|
||||
|
||||
public Hand(Dictionary<uint, Player> players, uint myPlayerId, uint smallBlind)
|
||||
{
|
||||
m_mutex = new Object();
|
||||
m_state = State.Preflop;
|
||||
m_players = players;
|
||||
m_myPlayerId = myPlayerId;
|
||||
m_smallBlind = smallBlind;
|
||||
m_pot = 0;
|
||||
}
|
||||
|
||||
public State CurState
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
if (m_state != value)
|
||||
{
|
||||
m_state = value;
|
||||
// Reset bets.
|
||||
foreach (KeyValuePair<uint, Player> player in m_players)
|
||||
{
|
||||
m_pot += player.Value.TotalBet;
|
||||
player.Value.TotalBet = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<uint, Player> Players
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
// Should not be modified. This is actually a const return ;-).
|
||||
return m_players;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint MyPlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
// no need to lock a mutex, this is read only.
|
||||
return m_myPlayerId;
|
||||
}
|
||||
}
|
||||
|
||||
public uint SmallBlind
|
||||
{
|
||||
get
|
||||
{
|
||||
// no need to lock a mutex, this is read only.
|
||||
return m_smallBlind;
|
||||
}
|
||||
}
|
||||
|
||||
public uint HighestSet
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_highestSet;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_highestSet = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint MinimumRaise
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_minimumRaise;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_minimumRaise = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] TableCards
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return (int[])m_tableCards.Clone();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_tableCards = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint Pot
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_pot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object m_mutex;
|
||||
private State m_state;
|
||||
private Dictionary<uint, Player> m_players;
|
||||
private int[] m_tableCards;
|
||||
readonly private uint m_myPlayerId;
|
||||
readonly private uint m_smallBlind;
|
||||
private uint m_highestSet;
|
||||
private uint m_minimumRaise;
|
||||
private uint m_pot;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public interface ICallback
|
||||
{
|
||||
void InitDone();
|
||||
void JoinedGame(string name);
|
||||
void GameStarted(List<string> players);
|
||||
void HandStarted(int[] cards);
|
||||
void SmallBlind(string name, uint blind);
|
||||
void BigBlind(string name, uint blind);
|
||||
void MyTurn(Hand.State state, uint highestSet, uint minimumRaise, uint money);
|
||||
void PlayersTurn(Hand.State state, string player);
|
||||
void ActionDone(string name, Hand.Action action, uint curBet, uint money, List<string> nonFoldPlayers);
|
||||
void ActionRejected();
|
||||
void ShowPot(uint pot);
|
||||
void ShowFlopCards(int[] cards);
|
||||
void ShowTurnCards(int[] cards);
|
||||
void ShowRiverCards(int[] cards);
|
||||
void AllInState();
|
||||
void ShowCards(string name, int[] cards);
|
||||
void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn);
|
||||
void HandResult();
|
||||
void PlayerWinsHand(string name, uint moneyWon);
|
||||
void PlayerWinsGame(string name);
|
||||
void RemovedFromGame();
|
||||
void ChatText(string name, string message);
|
||||
void Error(string message);
|
||||
void AvatarBegin(uint id, uint fileSize, GameInfo.AvatarFileType type);
|
||||
void AvatarData(uint id, byte[] block);
|
||||
void AvatarEnd(uint id);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class IdObject
|
||||
{
|
||||
public IdObject(uint id, string name)
|
||||
{
|
||||
m_id = id;
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
public uint Id
|
||||
{
|
||||
get
|
||||
{
|
||||
// No lock because only read access.
|
||||
return m_id;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
// No lock because only read access.
|
||||
return m_name;
|
||||
}
|
||||
}
|
||||
|
||||
readonly private uint m_id;
|
||||
readonly private string m_name;
|
||||
}
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* Inspired by log.cpp of the PokerTH client which is *
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class Log
|
||||
{
|
||||
public static string CardToString(int card)
|
||||
{
|
||||
int cardValue = card % 13;
|
||||
int cardColor = card / 13;
|
||||
string cardString;
|
||||
|
||||
switch (cardValue)
|
||||
{
|
||||
case 0:
|
||||
cardString = "2";
|
||||
break;
|
||||
case 1:
|
||||
cardString = "3";
|
||||
break;
|
||||
case 2:
|
||||
cardString = "4";
|
||||
break;
|
||||
case 3:
|
||||
cardString = "5";
|
||||
break;
|
||||
case 4:
|
||||
cardString = "6";
|
||||
break;
|
||||
case 5:
|
||||
cardString = "7";
|
||||
break;
|
||||
case 6:
|
||||
cardString = "8";
|
||||
break;
|
||||
case 7:
|
||||
cardString = "9";
|
||||
break;
|
||||
case 8:
|
||||
cardString = "T";
|
||||
break;
|
||||
case 9:
|
||||
cardString = "J";
|
||||
break;
|
||||
case 10:
|
||||
cardString = "Q";
|
||||
break;
|
||||
case 11:
|
||||
cardString = "K";
|
||||
break;
|
||||
case 12:
|
||||
cardString = "A";
|
||||
break;
|
||||
default:
|
||||
cardString = "Invalid Card ";
|
||||
break;
|
||||
}
|
||||
switch (cardColor)
|
||||
{
|
||||
case 0 :
|
||||
cardString += "d";
|
||||
break;
|
||||
case 1 :
|
||||
cardString += "h";
|
||||
break;
|
||||
case 2 :
|
||||
cardString += "s";
|
||||
break;
|
||||
case 3:
|
||||
cardString += "c";
|
||||
break;
|
||||
default:
|
||||
cardString += " Invalid Color";
|
||||
break;
|
||||
}
|
||||
return cardString;
|
||||
}
|
||||
|
||||
public static string StateToString(Hand.State state)
|
||||
{
|
||||
string stateString;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case Hand.State.Preflop :
|
||||
stateString = "Preflop";
|
||||
break;
|
||||
case Hand.State.Flop :
|
||||
stateString = "Flop";
|
||||
break;
|
||||
case Hand.State.Turn :
|
||||
stateString = "Turn";
|
||||
break;
|
||||
case Hand.State.River :
|
||||
stateString = "River";
|
||||
break;
|
||||
default :
|
||||
stateString = "Invalid state";
|
||||
break;
|
||||
}
|
||||
|
||||
return stateString;
|
||||
}
|
||||
|
||||
public static string ActionToString(Hand.Action action, uint curSet)
|
||||
{
|
||||
string actionString;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case Hand.Action.Fold:
|
||||
actionString = "folds";
|
||||
break;
|
||||
case Hand.Action.Check:
|
||||
actionString = "checks";
|
||||
break;
|
||||
case Hand.Action.Call:
|
||||
actionString = "calls";
|
||||
break;
|
||||
case Hand.Action.Bet:
|
||||
actionString = "bets";
|
||||
break;
|
||||
case Hand.Action.Raise:
|
||||
actionString = "bets";
|
||||
break;
|
||||
case Hand.Action.AllIn:
|
||||
actionString = "is all in with";
|
||||
break;
|
||||
default :
|
||||
actionString = "(invalid action)";
|
||||
break;
|
||||
}
|
||||
|
||||
if ((int)action >= 3)
|
||||
actionString += " $" + Convert.ToString(curSet);
|
||||
|
||||
return actionString;
|
||||
}
|
||||
|
||||
protected static string CardCodeToString(int cardCode, bool plural)
|
||||
{
|
||||
string cardString;
|
||||
|
||||
switch (cardCode)
|
||||
{
|
||||
case 12 :
|
||||
cardString = "Ace";
|
||||
break;
|
||||
case 11 :
|
||||
cardString = "King";
|
||||
break;
|
||||
case 10 :
|
||||
cardString = "Queen";
|
||||
break;
|
||||
case 9 :
|
||||
cardString = "Jack";
|
||||
break;
|
||||
case 8 :
|
||||
cardString = "Ten";
|
||||
break;
|
||||
case 7 :
|
||||
cardString = "Nine";
|
||||
break;
|
||||
case 6 :
|
||||
cardString = "Eight";
|
||||
break;
|
||||
case 5 :
|
||||
cardString = "Seven";
|
||||
break;
|
||||
case 4 :
|
||||
cardString = "Six";
|
||||
break;
|
||||
case 3 :
|
||||
cardString = "Five";
|
||||
break;
|
||||
case 2 :
|
||||
cardString = "Four";
|
||||
break;
|
||||
case 1 :
|
||||
cardString = "Three";
|
||||
break;
|
||||
case 0 :
|
||||
cardString = "Deuce";
|
||||
break;
|
||||
default :
|
||||
cardString = "Invalid Card";
|
||||
break;
|
||||
}
|
||||
if (plural)
|
||||
{
|
||||
if (cardCode == 4) // sixes
|
||||
cardString += "e";
|
||||
cardString += "s";
|
||||
}
|
||||
return cardString;
|
||||
}
|
||||
|
||||
public static string CardsValueToString(int cardsValue)
|
||||
{
|
||||
string cardString;
|
||||
|
||||
int firstPart = cardsValue / 100000000;
|
||||
int secondPart = cardsValue / 1000000 - firstPart * 100;
|
||||
int thirdPart = cardsValue / 10000 - firstPart * 10000
|
||||
- secondPart * 100;
|
||||
int fourthPart = cardsValue / 100 - firstPart * 1000000
|
||||
- secondPart * 10000 - thirdPart * 100;
|
||||
int fifthPart = cardsValue - firstPart * 100000000
|
||||
- secondPart * 1000000 - thirdPart * 10000 - fourthPart * 100;
|
||||
int fifthPartA = cardsValue / 10 - firstPart * 10000000
|
||||
- secondPart * 100000 - thirdPart * 1000 - fourthPart * 10;
|
||||
int fifthPartB = cardsValue - firstPart * 100000000
|
||||
- secondPart * 1000000 - thirdPart * 10000 - fourthPart*100
|
||||
- fifthPartA*10;
|
||||
|
||||
switch (firstPart)
|
||||
{
|
||||
// Royal Flush
|
||||
case 9 :
|
||||
cardString = "Royal Flush";
|
||||
break;
|
||||
// Straight Flush
|
||||
case 8 :
|
||||
cardString = "Straight Flush, ";
|
||||
if (secondPart >= 3)
|
||||
cardString += CardCodeToString(secondPart, false) + " high";
|
||||
else
|
||||
cardString += "Invalid high";
|
||||
break;
|
||||
// Four of a Kind
|
||||
case 7 :
|
||||
cardString = "Four of a Kind, " + CardCodeToString(secondPart, true);
|
||||
break;
|
||||
// Full House
|
||||
case 6 :
|
||||
cardString = "Full House, "
|
||||
+ CardCodeToString(secondPart, true)
|
||||
+ " full of "
|
||||
+ CardCodeToString(thirdPart, true);
|
||||
break;
|
||||
// Flush
|
||||
case 5 :
|
||||
cardString = "Flush, ";
|
||||
if (secondPart >= 4)
|
||||
cardString += CardCodeToString(secondPart, false) + " high";
|
||||
else
|
||||
cardString += "Invalid high";
|
||||
break;
|
||||
// Straight
|
||||
case 4 :
|
||||
cardString = "Straight, ";
|
||||
if (secondPart >= 3)
|
||||
cardString += CardCodeToString(secondPart, false) + " high";
|
||||
else
|
||||
cardString += "Invalid high";
|
||||
break;
|
||||
// Three of a Kind
|
||||
case 3 :
|
||||
cardString = "Three of a Kind, " + CardCodeToString(secondPart, true);
|
||||
break;
|
||||
// Two Pairs
|
||||
case 2 :
|
||||
cardString = "Two Pairs, "
|
||||
+ CardCodeToString(secondPart, true)
|
||||
+ " and "
|
||||
+ CardCodeToString(thirdPart, true);
|
||||
break;
|
||||
// One Pair
|
||||
case 1 :
|
||||
cardString = "One Pair, "
|
||||
+ CardCodeToString(secondPart, true);
|
||||
break;
|
||||
// Highest Card
|
||||
case 0 :
|
||||
cardString = "High Card, "
|
||||
+ CardCodeToString(secondPart, false);
|
||||
break;
|
||||
default:
|
||||
cardString = "Invalid Card Value";
|
||||
break;
|
||||
}
|
||||
return cardString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class Player
|
||||
{
|
||||
public Player()
|
||||
{
|
||||
m_mutex = new Object();
|
||||
m_curAction = Hand.Action.None;
|
||||
}
|
||||
|
||||
public int[] Cards
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
// Return a copy of the array.
|
||||
return (int[])m_cards.Clone();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_cards = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] BestHandPos
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
// Return a copy of the array.
|
||||
return (int[])m_bestHandPos.Clone();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_bestHandPos = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Hand.Action CurAction
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_curAction;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_curAction = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint Money
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_money;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_money = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint TotalBet
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_totalBet;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_totalBet = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CardsValue
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_cardsValue;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_cardsValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NewHand()
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_cards = null;
|
||||
m_curAction = Hand.Action.None;
|
||||
m_totalBet = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private Object m_mutex;
|
||||
private int[] m_cards;
|
||||
private int[] m_bestHandPos;
|
||||
private Hand.Action m_curAction;
|
||||
private uint m_money;
|
||||
private uint m_totalBet;
|
||||
private int m_cardsValue;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class PlayerInfo : IdObject
|
||||
{
|
||||
public PlayerInfo(uint id, string name)
|
||||
: base(id, name)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class PlayerInfoList
|
||||
{
|
||||
public PlayerInfoList()
|
||||
{
|
||||
m_list = new Dictionary<uint, PlayerInfo>();
|
||||
}
|
||||
|
||||
public void AddPlayerInfo(PlayerInfo info)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
if (m_list.ContainsKey(info.Id))
|
||||
m_list[info.Id] = info;
|
||||
else
|
||||
m_list.Add(info.Id, info);
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfo GetPlayerInfo(uint id)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
return m_list[id];
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasPlayer(uint id)
|
||||
{
|
||||
lock (m_list)
|
||||
{
|
||||
return m_list.ContainsKey(id);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string outString = "";
|
||||
lock (m_list)
|
||||
{
|
||||
foreach (KeyValuePair<uint, PlayerInfo> i in m_list)
|
||||
{
|
||||
outString += i.Value.Name;
|
||||
outString += '\n';
|
||||
}
|
||||
}
|
||||
return outString;
|
||||
}
|
||||
|
||||
private Dictionary<uint, PlayerInfo> m_list;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class PokerTHData
|
||||
{
|
||||
public PokerTHData(string name)
|
||||
{
|
||||
m_gameInfoList = new GameInfoList();
|
||||
m_playerInfoList = new PlayerInfoList();
|
||||
m_mutex = new Object();
|
||||
m_myPlayerId = 0;
|
||||
m_myGameId = 0;
|
||||
m_myName = name;
|
||||
m_joinedGame = false;
|
||||
}
|
||||
|
||||
public GameInfoList GameList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_gameInfoList;
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfoList PlayerList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_playerInfoList;
|
||||
}
|
||||
}
|
||||
|
||||
public Hand CurHand
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_curHand;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_curHand = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string MyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_myName;
|
||||
}
|
||||
}
|
||||
|
||||
public uint MyPlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_myPlayerId;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_myPlayerId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint MyGameId
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_myGameId;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_myGameId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool JoinedGame
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
return m_joinedGame;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (m_mutex)
|
||||
{
|
||||
m_joinedGame = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GameInfoList m_gameInfoList;
|
||||
private PlayerInfoList m_playerInfoList;
|
||||
private Hand m_curHand;
|
||||
private Object m_mutex;
|
||||
private uint m_myPlayerId;
|
||||
private uint m_myGameId;
|
||||
readonly private string m_myName;
|
||||
private bool m_joinedGame;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class ServerSettings
|
||||
{
|
||||
public ServerSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public string IPv4Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ipv4Address;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ipv4Address = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string IPv6Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ipv6Address;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ipv6Address = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_port = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Server
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_server;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_server = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string m_ipv4Address = "";
|
||||
private string m_ipv6Address = "";
|
||||
private string m_server = "";
|
||||
private int m_port = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
private const string ServerListUrl = "http://pokerth.net/serverlist.xml.z";
|
||||
|
||||
public Settings()
|
||||
{
|
||||
m_serverSettings = RetrieveServerSettings();
|
||||
}
|
||||
|
||||
public ServerSettings ServerSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_serverSettings;
|
||||
}
|
||||
}
|
||||
|
||||
protected ServerSettings RetrieveServerSettings()
|
||||
{
|
||||
// Retrieve server list.
|
||||
string tmpFile = DownloadXmlServerList();
|
||||
// Parse Xml data;
|
||||
ServerSettings settings = ParseServerSettings(tmpFile);
|
||||
File.Delete(tmpFile);
|
||||
return settings;
|
||||
}
|
||||
|
||||
protected string DownloadXmlServerList()
|
||||
{
|
||||
// Download the server list from the official site.
|
||||
WebClient webcl = new WebClient();
|
||||
string tmpFilePath = Path.GetTempPath();
|
||||
string tmpZipFile = tmpFilePath + "pokerth_serverlist.xml.z";
|
||||
string tmpXmlFile = tmpFilePath + "pokerth_serverlist.xml";
|
||||
webcl.DownloadFile(ServerListUrl, tmpZipFile);
|
||||
// The list is zlib compressed - uncompress.
|
||||
ZlibHelper.UncompressFile(tmpZipFile, tmpXmlFile);
|
||||
File.Delete(tmpZipFile);
|
||||
|
||||
return tmpXmlFile;
|
||||
}
|
||||
|
||||
protected ServerSettings ParseServerSettings(string file)
|
||||
{
|
||||
ServerSettings settings = new ServerSettings();
|
||||
FileStream f = new FileStream(file, FileMode.Open, FileAccess.Read);
|
||||
XmlReader x = XmlReader.Create(f);
|
||||
x.Read();
|
||||
x.ReadStartElement("ServerList");
|
||||
x.ReadStartElement("Server");
|
||||
x.ReadToFollowing("IPv4Address");
|
||||
x.MoveToFirstAttribute();
|
||||
settings.IPv4Address = x.Value;
|
||||
x.ReadToFollowing("IPv6Address");
|
||||
x.MoveToFirstAttribute();
|
||||
settings.IPv6Address = x.Value;
|
||||
x.ReadToFollowing("Port");
|
||||
x.MoveToFirstAttribute();
|
||||
settings.Port = Convert.ToInt32(x.Value);
|
||||
x.Close();
|
||||
f.Close();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
private ServerSettings m_serverSettings;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public abstract class TestThread : BasicThread
|
||||
{
|
||||
public TestThread(string serverAddress, uint id)
|
||||
{
|
||||
m_id = id;
|
||||
m_serverAddress = serverAddress;
|
||||
m_client = new TcpClient();
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
bool isConnected = false;
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
m_client.Connect(m_serverAddress, 7234);
|
||||
isConnected = true;
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
} while (!isConnected);
|
||||
m_client.NoDelay = true;
|
||||
}
|
||||
|
||||
public void SendInit(string userName)
|
||||
{
|
||||
// Send init.
|
||||
NetPacket init = NetPacket.Create(NetPacket.NetTypeInit);
|
||||
init.Properties.Add(NetPacket.PropType.RequestedVersionMajor, "5");
|
||||
init.Properties.Add(NetPacket.PropType.RequestedVersionMinor, "2");
|
||||
init.Properties.Add(NetPacket.PropType.PlayerName, userName);
|
||||
init.Properties.Add(NetPacket.PropType.ServerPassword, "");
|
||||
byte[] outBuf = init.ToByteArray();
|
||||
m_client.GetStream().Write(outBuf, 0, outBuf.Length);
|
||||
}
|
||||
|
||||
public static void ReadFromStream(NetworkStream stream, byte[] buf, int bufOffset, int numBytes)
|
||||
{
|
||||
int bytesRead = 0;
|
||||
do
|
||||
{
|
||||
while (!stream.DataAvailable)
|
||||
Thread.Sleep(20);
|
||||
bytesRead += stream.Read(buf, bufOffset + bytesRead, numBytes - bytesRead);
|
||||
} while (bytesRead != numBytes);
|
||||
}
|
||||
|
||||
public int ReadNextPacket(out byte[] packet)
|
||||
{
|
||||
byte[] header = new byte[4];
|
||||
NetworkStream stream = m_client.GetStream();
|
||||
ReadFromStream(stream, header, 0, 4);
|
||||
MemoryStream memStream = new MemoryStream(header);
|
||||
BinaryReader r = new BinaryReader(memStream);
|
||||
int type = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
int size = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
if (size < 4)
|
||||
{
|
||||
throw new InvalidDataException("Invalid packet size.");
|
||||
}
|
||||
packet = new byte[size];
|
||||
header.CopyTo(packet, 0);
|
||||
ReadFromStream(stream, packet, 4, size - 4);
|
||||
return type;
|
||||
}
|
||||
|
||||
public void WaitForPacket(int waitType)
|
||||
{
|
||||
int type;
|
||||
byte[] packet = null;
|
||||
do
|
||||
{
|
||||
type = ReadNextPacket(out packet);
|
||||
} while (type != waitType);
|
||||
}
|
||||
|
||||
protected uint m_id;
|
||||
protected TcpClient m_client;
|
||||
protected string m_serverAddress;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using zlib;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class ZlibHelper
|
||||
{
|
||||
public static void UncompressFile(string compressedFile, string outputFile)
|
||||
{
|
||||
ZStream zStream = new ZStream();
|
||||
zStream.inflateInit();
|
||||
FileStream inputStream = File.Open(compressedFile, FileMode.Open,FileAccess.Read);
|
||||
FileStream outputStream = File.Open(outputFile, FileMode.Create, FileAccess.Write);
|
||||
const int InBufSize = 4096;
|
||||
const int OutBufSize = 8192;
|
||||
byte[] inBuf = new byte[InBufSize];
|
||||
byte[] outBuf = new byte[OutBufSize];
|
||||
int bytesRead;
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
bytesRead = inputStream.Read(inBuf, 0, InBufSize);
|
||||
if (bytesRead == 0)
|
||||
throw new IOException("Unexpected end-of-file during uncompression.");
|
||||
|
||||
zStream.next_in = inBuf;
|
||||
zStream.next_in_index = 0;
|
||||
zStream.avail_in = bytesRead;
|
||||
do
|
||||
{
|
||||
zStream.next_out = outBuf;
|
||||
zStream.next_out_index = 0;
|
||||
zStream.avail_out = OutBufSize;
|
||||
ret = zStream.inflate(zlibConst.Z_NO_FLUSH);
|
||||
|
||||
if (ret != zlibConst.Z_OK && ret != zlibConst.Z_STREAM_END)
|
||||
throw new IOException("Error uncompressing file: " + zStream.msg);
|
||||
outputStream.Write(outBuf, 0, OutBufSize - zStream.avail_out);
|
||||
} while (zStream.avail_out == 0);
|
||||
} while (ret != zlibConst.Z_STREAM_END);
|
||||
zStream.inflateEnd();
|
||||
// Close files here, because otherwise it might take some time.
|
||||
inputStream.Close();
|
||||
outputStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public Client(Settings settings, PokerTHData data, ICallback callback)
|
||||
{
|
||||
m_tcpClient = new TcpClient();
|
||||
m_settings = settings;
|
||||
m_data = data;
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
// Connect to the server.
|
||||
// If the user specified a server, try this.
|
||||
if (m_settings.ServerSettings.Server.Length > 0)
|
||||
m_tcpClient.Connect(
|
||||
m_settings.ServerSettings.Server, m_settings.ServerSettings.Port);
|
||||
else
|
||||
{
|
||||
// Try IPv6 first.
|
||||
/*IPAddress[] addresses = new IPAddress[2];
|
||||
addresses[0] = IPAddress.Parse(m_settings.ServerSettings.IPv6Address);
|
||||
addresses[1] = IPAddress.Parse(m_settings.ServerSettings.IPv4Address);
|
||||
m_tcpClient.Connect(addresses, m_settings.ServerSettings.Port);*/
|
||||
m_tcpClient.Connect("localhost", 7234);
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
StartSendThread();
|
||||
StartReceiveThread();
|
||||
SendInit();
|
||||
}
|
||||
|
||||
public void JoinGame(uint gameId, string password)
|
||||
{
|
||||
SendJoinGame(gameId, password);
|
||||
}
|
||||
|
||||
public bool HasJoinedGame()
|
||||
{
|
||||
return m_data.JoinedGame;
|
||||
}
|
||||
|
||||
public void MyAction(Hand.Action action, uint bet)
|
||||
{
|
||||
NetPacket a = new NetPacketPlayersAction();
|
||||
a.Properties.Add(
|
||||
NetPacket.PropType.GameState,
|
||||
Convert.ToString((int)m_data.CurHand.CurState));
|
||||
a.Properties.Add(
|
||||
NetPacket.PropType.PlayerAction,
|
||||
Convert.ToString((int)action));
|
||||
a.Properties.Add(
|
||||
NetPacket.PropType.PlayerBet,
|
||||
Convert.ToString(bet));
|
||||
m_sender.Send(a);
|
||||
}
|
||||
|
||||
public void SetTerminateFlag()
|
||||
{
|
||||
m_sender.SetTerminateFlag();
|
||||
m_receiver.SetTerminateFlag();
|
||||
}
|
||||
|
||||
public void WaitTermination()
|
||||
{
|
||||
m_sender.WaitTermination();
|
||||
m_receiver.WaitTermination();
|
||||
}
|
||||
|
||||
protected void StartReceiveThread()
|
||||
{
|
||||
m_receiver = new ReceiverThread(m_tcpClient.GetStream(), m_sender, m_data, m_callback);
|
||||
m_receiver.Run();
|
||||
}
|
||||
|
||||
protected void StartSendThread()
|
||||
{
|
||||
m_sender = new SenderThread(m_tcpClient.GetStream());
|
||||
m_sender.Run();
|
||||
}
|
||||
|
||||
protected void SendInit()
|
||||
{
|
||||
NetPacket init = new NetPacketInit();
|
||||
init.Properties.Add(NetPacket.PropType.RequestedVersionMajor, "5");
|
||||
init.Properties.Add(NetPacket.PropType.RequestedVersionMinor, "0");
|
||||
init.Properties.Add(NetPacket.PropType.PlayerName, m_data.MyName);
|
||||
init.Properties.Add(NetPacket.PropType.ServerPassword, "");
|
||||
m_sender.Send(init);
|
||||
}
|
||||
|
||||
protected void SendJoinGame(uint gameId, string password)
|
||||
{
|
||||
NetPacket join = new NetPacketJoinGame();
|
||||
join.Properties.Add(NetPacket.PropType.GameId, Convert.ToString(gameId));
|
||||
join.Properties.Add(NetPacket.PropType.GamePassword, password);
|
||||
m_sender.Send(join);
|
||||
}
|
||||
|
||||
private TcpClient m_tcpClient;
|
||||
private ReceiverThread m_receiver;
|
||||
private SenderThread m_sender;
|
||||
private Settings m_settings;
|
||||
private PokerTHData m_data;
|
||||
private ICallback m_callback;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public interface INetPacketVisitor
|
||||
{
|
||||
void VisitInit(NetPacket p);
|
||||
void VisitInitAck(NetPacket p);
|
||||
void VisitGameListNew(NetPacket p);
|
||||
void VisitGameListUpdate(NetPacket p);
|
||||
void VisitGameListPlayerJoined(NetPacket p);
|
||||
void VisitGameListPlayerLeft(NetPacket p);
|
||||
void VisitRetrievePlayerInfo(NetPacket p);
|
||||
void VisitPlayerInfo(NetPacket p);
|
||||
void VisitCreateGame(NetPacket p);
|
||||
void VisitJoinGame(NetPacket p);
|
||||
void VisitJoinGameAck(NetPacket p);
|
||||
void VisitLeaveCurrentGame(NetPacket p);
|
||||
void VisitStartEvent(NetPacket p);
|
||||
void VisitStartEventAck(NetPacket p);
|
||||
void VisitGameStart(NetPacket p);
|
||||
void VisitHandStart(NetPacket p);
|
||||
void VisitPlayersTurn(NetPacket p);
|
||||
void VisitPlayersAction(NetPacket p);
|
||||
void VisitPlayersActionDone(NetPacket p);
|
||||
void VisitPlayersActionRejected(NetPacket p);
|
||||
void VisitDealFlopCards(NetPacket p);
|
||||
void VisitDealTurnCard(NetPacket p);
|
||||
void VisitDealRiverCard(NetPacket p);
|
||||
void VisitAllInShowCards(NetPacket p);
|
||||
void VisitEndOfHandShowCards(NetPacket p);
|
||||
void VisitEndOfHandHideCards(NetPacket p);
|
||||
void VisitEndOfGame(NetPacket p);
|
||||
void VisitRemovedFromGame(NetPacket p);
|
||||
void VisitChatText(NetPacket p);
|
||||
void VisitError(NetPacket p);
|
||||
void VisitRetrieveAvatar(NetPacket p);
|
||||
void VisitAvatarHeader(NetPacket p);
|
||||
void VisitAvatarFile(NetPacket p);
|
||||
void VisitAvatarEnd(NetPacket p);
|
||||
void VisitUnknownAvatar(NetPacket p);
|
||||
}
|
||||
}
|
||||
@@ -1,529 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public abstract class NetPacket
|
||||
{
|
||||
public const int NetTypeInit = 0x0001;
|
||||
public const int NetTypeInitAck = 0x0002;
|
||||
public const int NetTypeRetrieveAvatar = 0x0003;
|
||||
public const int NetTypeAvatarHeader = 0x0004;
|
||||
public const int NetTypeAvatarFile = 0x0005;
|
||||
public const int NetTypeAvatarEnd = 0x0006;
|
||||
public const int NetTypeUnknownAvatar = 0x0007;
|
||||
public const int NetTypeGameListNew = 0x0010;
|
||||
public const int NetTypeGameListUpdate = 0x0011;
|
||||
public const int NetTypeGameListPlayerJoined = 0x0012;
|
||||
public const int NetTypeGameListPlayerLeft = 0x0013;
|
||||
public const int NetTypeGameListAdminChanged = 0x0014;
|
||||
public const int NetTypeRetrievePlayerInfo = 0x0020;
|
||||
public const int NetTypePlayerInfo = 0x0021;
|
||||
public const int NetTypeUnknownPlayerId = 0x0022;
|
||||
public const int NetTypeUnsubscribeGameList = 0x0023;
|
||||
public const int NetTypeResubscribeGameList = 0x0024;
|
||||
public const int NetTypeCreateGame = 0x0030;
|
||||
public const int NetTypeJoinGame = 0x0031;
|
||||
public const int NetTypeJoinGameAck = 0x0032;
|
||||
public const int NetTypeJoinGameFailed = 0x0033;
|
||||
public const int NetTypePlayerJoined = 0x0034;
|
||||
public const int NetTypePlayerLeft = 0x0035;
|
||||
public const int NetTypeGameAdminChanged = 0x0036;
|
||||
public const int NetTypeKickPlayer = 0x0040;
|
||||
public const int NetTypeLeaveCurrentGame = 0x0041;
|
||||
public const int NetTypeStartEvent = 0x0042;
|
||||
public const int NetTypeStartEventAck = 0x0043;
|
||||
public const int NetTypeGameStart = 0x0050;
|
||||
public const int NetTypeHandStart = 0x0051;
|
||||
public const int NetTypePlayersTurn = 0x0052;
|
||||
public const int NetTypePlayersAction = 0x0053;
|
||||
public const int NetTypePlayersActionDone = 0x0054;
|
||||
public const int NetTypePlayersActionRejected = 0x0055;
|
||||
public const int NetTypeDealFlopCards = 0x0060;
|
||||
public const int NetTypeDealTurnCard = 0x0061;
|
||||
public const int NetTypeDealRiverCard = 0x0062;
|
||||
public const int NetTypeAllInShowCards = 0x0063;
|
||||
public const int NetTypeEndOfHandShowCards = 0x0064;
|
||||
public const int NetTypeEndOfHandHideCards = 0x0065;
|
||||
public const int NetTypeEndOfGame = 0x0070;
|
||||
public const int NetTypeAskKickPlayer = 0x0071;
|
||||
public const int NetTypeAskKickPlayerDenied = 0x0072;
|
||||
public const int NetTypeStartKickPlayerPetition = 0x0073;
|
||||
public const int NetTypeVoteKickPlayer = 0x0074;
|
||||
public const int NetTypeVoteKickPlayerAck = 0x0075;
|
||||
public const int NetTypeVoteKickPlayerDenied = 0x0076;
|
||||
public const int NetTypeKickPlayerPetitionUpdate = 0x0077;
|
||||
public const int NetTypeEndKickPlayerPetition = 0x0078;
|
||||
|
||||
public const int NetTypeStatisticsChanged = 0x0080;
|
||||
|
||||
public const int NetTypeRemovedFromGame = 0x0100;
|
||||
public const int NetTypeTimeoutWarning = 0x0101;
|
||||
public const int NetTypeResetTimeout = 0x0102;
|
||||
|
||||
public const int NetTypeSendChatText = 0x0200;
|
||||
public const int NetTypeChatText = 0x0201;
|
||||
|
||||
public const int NetTypeError = 0x0400;
|
||||
|
||||
public enum PropType
|
||||
{
|
||||
RequestedVersionMajor,
|
||||
RequestedVersionMinor,
|
||||
PlayerId,
|
||||
PlayerName,
|
||||
ServerPassword,
|
||||
PlayerFlags,
|
||||
PlayerRights,
|
||||
PlayerAction,
|
||||
PlayerBet,
|
||||
PlayerBetTotal,
|
||||
PlayerMoney,
|
||||
LatestGameVersion,
|
||||
LatestBetaRevision,
|
||||
SessionId,
|
||||
GameId,
|
||||
GameMode,
|
||||
GameName,
|
||||
GamePrivacyFlags,
|
||||
GamePassword,
|
||||
GameState,
|
||||
AdminPlayerId,
|
||||
MaxNumPlayers,
|
||||
RaiseIntervalMode,
|
||||
RaiseSmallBlindInterval,
|
||||
RaiseMode,
|
||||
EndRaiseMode,
|
||||
ProposedGuiSpeed,
|
||||
PlayerActionTimeout,
|
||||
FirstSmallBlind,
|
||||
EndRaiseSmallBlindValue,
|
||||
StartMoney,
|
||||
CurNumPlayers,
|
||||
StartFlags,
|
||||
StartDealerPlayerId,
|
||||
FirstCard,
|
||||
SecondCard,
|
||||
SmallBlind,
|
||||
HighestSet,
|
||||
MinimumRaise,
|
||||
ActionRejectReason,
|
||||
FlopFirstCard,
|
||||
FlopSecondCard,
|
||||
FlopThirdCard,
|
||||
TurnCard,
|
||||
RiverCard,
|
||||
MoneyWon,
|
||||
BestHandPos1,
|
||||
BestHandPos2,
|
||||
BestHandPos3,
|
||||
BestHandPos4,
|
||||
BestHandPos5,
|
||||
CardsValue,
|
||||
ChatText,
|
||||
ErrorReason,
|
||||
RemoveReason,
|
||||
RequestId,
|
||||
AvatarMD5,
|
||||
AvatarFileSize,
|
||||
AvatarFileType,
|
||||
AvatarBlockSize,
|
||||
AvatarFileData,
|
||||
}
|
||||
|
||||
public enum ListPropType
|
||||
{
|
||||
PlayerSlots,
|
||||
ManualBlindSlots,
|
||||
}
|
||||
|
||||
public enum RecordPropType
|
||||
{
|
||||
PlayerResults,
|
||||
PlayerCards,
|
||||
}
|
||||
|
||||
public static NetPacket Create(int type)
|
||||
{
|
||||
NetPacket tmpPacket = null;
|
||||
switch (type)
|
||||
{
|
||||
// Virtual constructor.
|
||||
case NetTypeInit :
|
||||
tmpPacket = new NetPacketInit();
|
||||
break;
|
||||
case NetTypeInitAck :
|
||||
tmpPacket = new NetPacketInitAck();
|
||||
break;
|
||||
//case NetTypeRetrieveAvatar :
|
||||
//case NetTypeAvatarHeader :
|
||||
//case NetTypeAvatarFile :
|
||||
//case NetTypeAvatarEnd :
|
||||
//case NetTypeUnknownAvatar :
|
||||
case NetTypeGameListNew :
|
||||
tmpPacket = new NetPacketGameListNew();
|
||||
break;
|
||||
case NetTypeGameListUpdate :
|
||||
tmpPacket = new NetPacketGameListUpdate();
|
||||
break;
|
||||
case NetTypeGameListPlayerJoined :
|
||||
tmpPacket = new NetPacketGameListPlayerJoined();
|
||||
break;
|
||||
case NetTypeGameListPlayerLeft :
|
||||
tmpPacket = new NetPacketGameListPlayerLeft();
|
||||
break;
|
||||
//case NetTypeGameListAdminChanged :
|
||||
// tmpPacket = new NetPacketGameListAdminChanged();
|
||||
// break;
|
||||
case NetTypeRetrievePlayerInfo :
|
||||
tmpPacket = new NetPacketRetrievePlayerInfo();
|
||||
break;
|
||||
case NetTypePlayerInfo :
|
||||
tmpPacket = new NetPacketPlayerInfo();
|
||||
break;
|
||||
//case NetTypeUnknownPlayerId :
|
||||
case NetTypeUnsubscribeGameList :
|
||||
tmpPacket = new NetPacketUnsubscribeGameList();
|
||||
break;
|
||||
//case NetTypeResubscribeGameList :
|
||||
case NetTypeCreateGame :
|
||||
tmpPacket = new NetPacketCreateGame();
|
||||
break;
|
||||
case NetTypeJoinGame :
|
||||
tmpPacket = new NetPacketJoinGame();
|
||||
break;
|
||||
case NetTypeJoinGameAck :
|
||||
tmpPacket = new NetPacketJoinGameAck();
|
||||
break;
|
||||
//case NetTypeJoinGameFailed :
|
||||
// tmpPacket = new NetPacketJoinGameFailed();
|
||||
// break;
|
||||
//case NetTypePlayerJoined :
|
||||
//case NetTypePlayerLeft :
|
||||
//case NetTypeGameAdminChanged :
|
||||
//case NetTypeKickPlayer :
|
||||
case NetTypeLeaveCurrentGame :
|
||||
tmpPacket = new NetPacketLeaveCurrentGame();
|
||||
break;
|
||||
case NetTypeStartEvent :
|
||||
tmpPacket = new NetPacketStartEvent();
|
||||
break;
|
||||
case NetTypeStartEventAck :
|
||||
tmpPacket = new NetPacketStartEventAck();
|
||||
break;
|
||||
case NetTypeGameStart :
|
||||
tmpPacket = new NetPacketGameStart();
|
||||
break;
|
||||
case NetTypeHandStart :
|
||||
tmpPacket = new NetPacketHandStart();
|
||||
break;
|
||||
case NetTypePlayersTurn :
|
||||
tmpPacket = new NetPacketPlayersTurn();
|
||||
break;
|
||||
case NetTypePlayersAction :
|
||||
tmpPacket = new NetPacketPlayersAction();
|
||||
break;
|
||||
case NetTypePlayersActionDone :
|
||||
tmpPacket = new NetPacketPlayersActionDone();
|
||||
break;
|
||||
case NetTypePlayersActionRejected :
|
||||
tmpPacket = new NetPacketPlayersActionRejected();
|
||||
break;
|
||||
case NetTypeDealFlopCards :
|
||||
tmpPacket = new NetPacketDealFlopCards();
|
||||
break;
|
||||
case NetTypeDealTurnCard :
|
||||
tmpPacket = new NetPacketDealTurnCard();
|
||||
break;
|
||||
case NetTypeDealRiverCard :
|
||||
tmpPacket = new NetPacketDealRiverCard();
|
||||
break;
|
||||
case NetTypeAllInShowCards :
|
||||
tmpPacket = new NetPacketAllInShowCards();
|
||||
break;
|
||||
case NetTypeEndOfHandShowCards :
|
||||
tmpPacket = new NetPacketEndOfHandShowCards();
|
||||
break;
|
||||
case NetTypeEndOfHandHideCards :
|
||||
tmpPacket = new NetPacketEndOfHandHideCards();
|
||||
break;
|
||||
case NetTypeEndOfGame :
|
||||
tmpPacket = new NetPacketEndOfGame();
|
||||
break;
|
||||
//case NetTypeAskKickPlayer :
|
||||
//case NetTypeAskKickPlayerDenied :
|
||||
//case NetTypeStartKickPlayerPetition :
|
||||
//case NetTypeVoteKickPlayer :
|
||||
//case NetTypeVoteKickPlayerAck :
|
||||
//case NetTypeVoteKickPlayerDenied :
|
||||
//case NetTypeKickPlayerPetitionUpdate :
|
||||
//case NetTypeEndKickPlayerPetition :
|
||||
//case NetTypeStatisticsChanged :
|
||||
case NetTypeRemovedFromGame :
|
||||
tmpPacket = new NetPacketRemovedFromGame();
|
||||
break;
|
||||
//case NetTypeTimeoutWarning :
|
||||
//case NetTypeResetTimeout :
|
||||
//case NetTypeSendChatText :
|
||||
case NetTypeChatText :
|
||||
tmpPacket = new NetPacketChatText();
|
||||
break;
|
||||
case NetTypeError :
|
||||
tmpPacket = new NetPacketError();
|
||||
break;
|
||||
case NetTypeRetrieveAvatar :
|
||||
tmpPacket = new NetPacketRetrieveAvatar();
|
||||
break;
|
||||
}
|
||||
return tmpPacket;
|
||||
}
|
||||
|
||||
public static NetPacket Create(int type, int size, BinaryReader reader)
|
||||
{
|
||||
NetPacket tmpPacket = null;
|
||||
switch (type)
|
||||
{
|
||||
// Only consider those packets which are sent by the server.
|
||||
case NetTypeInitAck :
|
||||
tmpPacket = new NetPacketInitAck(size, reader);
|
||||
break;
|
||||
case NetTypeGameListNew :
|
||||
tmpPacket = new NetPacketGameListNew(size, reader);
|
||||
break;
|
||||
case NetTypeGameListUpdate :
|
||||
tmpPacket = new NetPacketGameListUpdate(size, reader);
|
||||
break;
|
||||
case NetTypeGameListPlayerJoined :
|
||||
tmpPacket = new NetPacketGameListPlayerJoined(size, reader);
|
||||
break;
|
||||
case NetTypeGameListPlayerLeft :
|
||||
tmpPacket = new NetPacketGameListPlayerLeft(size, reader);
|
||||
break;
|
||||
case NetTypeJoinGameAck :
|
||||
tmpPacket = new NetPacketJoinGameAck(size, reader);
|
||||
break;
|
||||
case NetTypePlayerInfo :
|
||||
tmpPacket = new NetPacketPlayerInfo(size, reader);
|
||||
break;
|
||||
case NetTypeStartEvent :
|
||||
tmpPacket = new NetPacketStartEvent(size, reader);
|
||||
break;
|
||||
case NetTypeGameStart :
|
||||
tmpPacket = new NetPacketGameStart(size, reader);
|
||||
break;
|
||||
case NetTypeHandStart :
|
||||
tmpPacket = new NetPacketHandStart(size, reader);
|
||||
break;
|
||||
case NetTypePlayersTurn :
|
||||
tmpPacket = new NetPacketPlayersTurn(size, reader);
|
||||
break;
|
||||
case NetTypePlayersActionDone :
|
||||
tmpPacket = new NetPacketPlayersActionDone(size, reader);
|
||||
break;
|
||||
case NetTypePlayersActionRejected :
|
||||
tmpPacket = new NetPacketPlayersActionRejected(size, reader);
|
||||
break;
|
||||
case NetTypeDealFlopCards :
|
||||
tmpPacket = new NetPacketDealFlopCards(size, reader);
|
||||
break;
|
||||
case NetTypeDealTurnCard :
|
||||
tmpPacket = new NetPacketDealTurnCard(size, reader);
|
||||
break;
|
||||
case NetTypeDealRiverCard :
|
||||
tmpPacket = new NetPacketDealRiverCard(size, reader);
|
||||
break;
|
||||
case NetTypeAllInShowCards :
|
||||
tmpPacket = new NetPacketAllInShowCards(size, reader);
|
||||
break;
|
||||
case NetTypeEndOfHandShowCards :
|
||||
tmpPacket = new NetPacketEndOfHandShowCards(size, reader);
|
||||
break;
|
||||
case NetTypeEndOfHandHideCards :
|
||||
tmpPacket = new NetPacketEndOfHandHideCards(size, reader);
|
||||
break;
|
||||
case NetTypeEndOfGame :
|
||||
tmpPacket = new NetPacketEndOfGame(size, reader);
|
||||
break;
|
||||
case NetTypeRemovedFromGame :
|
||||
tmpPacket = new NetPacketRemovedFromGame(size, reader);
|
||||
break;
|
||||
case NetTypeChatText :
|
||||
tmpPacket = new NetPacketChatText(size, reader);
|
||||
break;
|
||||
case NetTypeError :
|
||||
tmpPacket = new NetPacketError(size, reader);
|
||||
break;
|
||||
case NetTypeRetrieveAvatar :
|
||||
tmpPacket = new NetPacketRetrieveAvatar(size, reader);
|
||||
break;
|
||||
case NetTypeAvatarHeader :
|
||||
tmpPacket = new NetPacketAvatarHeader(size, reader);
|
||||
break;
|
||||
case NetTypeAvatarFile :
|
||||
tmpPacket = new NetPacketAvatarFile(size, reader);
|
||||
break;
|
||||
case NetTypeAvatarEnd :
|
||||
tmpPacket = new NetPacketAvatarEnd(size, reader);
|
||||
break;
|
||||
case NetTypeUnknownAvatar :
|
||||
tmpPacket = new NetPacketUnknownAvatar(size, reader);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return tmpPacket;
|
||||
}
|
||||
|
||||
public NetPacket(int type)
|
||||
{
|
||||
m_type = type;
|
||||
m_properties = new Dictionary<PropType, string>();
|
||||
m_listProperties = new Dictionary<ListPropType, List<string>>();
|
||||
m_recordProperties = new Dictionary<RecordPropType, List<Dictionary<PropType, string>>>();
|
||||
}
|
||||
|
||||
public Dictionary<PropType, string> Properties
|
||||
{
|
||||
set
|
||||
{
|
||||
m_properties = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return m_properties;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<ListPropType, List<string>> ListProperties
|
||||
{
|
||||
set
|
||||
{
|
||||
m_listProperties = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return m_listProperties;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<RecordPropType, List<Dictionary<PropType, string>>> RecordProperties
|
||||
{
|
||||
set
|
||||
{
|
||||
m_recordProperties = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return m_recordProperties;
|
||||
}
|
||||
}
|
||||
|
||||
public int Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Accept(INetPacketVisitor visitor);
|
||||
|
||||
public abstract byte[] ToByteArray();
|
||||
|
||||
static protected int AddPadding(int size)
|
||||
{
|
||||
return ((((size) + 3) / 4) * 4);
|
||||
}
|
||||
|
||||
protected void ScanGameInfoBlock(BinaryReader r)
|
||||
{
|
||||
Properties.Add(PropType.MaxNumPlayers,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.RaiseIntervalMode,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.RaiseSmallBlindInterval,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.RaiseMode,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.EndRaiseMode,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
int numManualBlinds = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
Properties.Add(PropType.ProposedGuiSpeed,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.PlayerActionTimeout,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.FirstSmallBlind,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.EndRaiseSmallBlindValue,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.StartMoney,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
|
||||
// Scan manual blinds.
|
||||
List<string> blindSlots = new List<string>();
|
||||
for (int i = 0; i < numManualBlinds; i++)
|
||||
blindSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
ListProperties.Add(ListPropType.ManualBlindSlots, blindSlots);
|
||||
}
|
||||
|
||||
protected void WriteGameInfoBlock(BinaryWriter w)
|
||||
{
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.MaxNumPlayers])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.RaiseIntervalMode])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.RaiseSmallBlindInterval])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.RaiseMode])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.EndRaiseMode])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
ListProperties[ListPropType.ManualBlindSlots].Count));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.ProposedGuiSpeed])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.PlayerActionTimeout])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.FirstSmallBlind])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.EndRaiseSmallBlindValue])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.StartMoney])));
|
||||
|
||||
foreach (string s in ListProperties[ListPropType.ManualBlindSlots])
|
||||
{
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(s)));
|
||||
}
|
||||
}
|
||||
|
||||
private int m_type;
|
||||
private Dictionary<PropType, string> m_properties;
|
||||
private Dictionary<ListPropType, List<string>> m_listProperties;
|
||||
private Dictionary<RecordPropType, List<Dictionary<PropType, string>>> m_recordProperties;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketAllInShowCards : NetPacket
|
||||
{
|
||||
public NetPacketAllInShowCards()
|
||||
: base(NetPacket.NetTypeAllInShowCards)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketAllInShowCards(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeAllInShowCards)
|
||||
{
|
||||
if (size < 16)
|
||||
throw new NetPacketException("NetPacketAllInShowCards invalid size.");
|
||||
int numPlayerCards = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
r.ReadUInt16(); //reserved
|
||||
|
||||
List<Dictionary<PropType, string>> tmpRecordList = new List<Dictionary<PropType, string>>();
|
||||
for (int i = 0; i < numPlayerCards; i++)
|
||||
{
|
||||
Dictionary<PropType, string> tmpList = new Dictionary<PropType, string>();
|
||||
tmpList.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.FirstCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.SecondCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
|
||||
tmpRecordList.Add(tmpList);
|
||||
}
|
||||
RecordProperties.Add(RecordPropType.PlayerCards, tmpRecordList);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitAllInShowCards(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketAvatarEnd : NetPacket
|
||||
{
|
||||
public NetPacketAvatarEnd()
|
||||
: base(NetPacket.NetTypeAvatarEnd)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketAvatarEnd(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeAvatarEnd)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketAvatarEnd invalid size.");
|
||||
Properties.Add(PropType.RequestId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitAvatarEnd(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketAvatarFile : NetPacket
|
||||
{
|
||||
public NetPacketAvatarFile()
|
||||
: base(NetPacket.NetTypeAvatarFile)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketAvatarFile(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeAvatarFile)
|
||||
{
|
||||
if (size < 12)
|
||||
throw new NetPacketException("NetPacketAvatarFile invalid size.");
|
||||
Properties.Add(PropType.RequestId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
int avatarBlockSize = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
Properties.Add(PropType.AvatarBlockSize,
|
||||
Convert.ToString(avatarBlockSize));
|
||||
r.ReadUInt16(); // reserved
|
||||
Properties.Add(PropType.AvatarFileData,
|
||||
Convert.ToBase64String(r.ReadBytes(avatarBlockSize)));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitAvatarFile(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketAvatarHeader : NetPacket
|
||||
{
|
||||
public NetPacketAvatarHeader()
|
||||
: base(NetPacket.NetTypeAvatarHeader)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketAvatarHeader(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeAvatarHeader)
|
||||
{
|
||||
if (size != 16)
|
||||
throw new NetPacketException("NetPacketAvatarHeader invalid size.");
|
||||
Properties.Add(PropType.RequestId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.AvatarFileSize,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.AvatarFileType,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitAvatarHeader(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketChatText : NetPacket
|
||||
{
|
||||
public NetPacketChatText()
|
||||
: base(NetPacket.NetTypeChatText)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketChatText(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeChatText)
|
||||
{
|
||||
if (size < 12)
|
||||
throw new NetPacketException("NetPacketChatText invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
int textLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
|
||||
r.ReadUInt16(); // reserved
|
||||
|
||||
// Read chat text.
|
||||
byte[] tmpText = r.ReadBytes(textLen);
|
||||
Properties.Add(PropType.ChatText,
|
||||
Encoding.UTF8.GetString(tmpText));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitChatText(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketCreateGame : NetPacket
|
||||
{
|
||||
public NetPacketCreateGame()
|
||||
: base(NetPacket.NetTypeCreateGame)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitCreateGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
string gamePassword = Properties[PropType.GamePassword];
|
||||
byte[] tmpPassword = Encoding.UTF8.GetBytes(gamePassword);
|
||||
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
||||
string gameName = Properties[PropType.GameName];
|
||||
byte[] tmpName = Encoding.UTF8.GetBytes(gameName);
|
||||
int nameWithPadding = AddPadding(tmpName.Length);
|
||||
int numBlindSlots = ListProperties[ListPropType.ManualBlindSlots].Count;
|
||||
int size = 8 + 28 + numBlindSlots * 4 + passwordWithPadding + nameWithPadding;
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)gameName.Length));
|
||||
|
||||
WriteGameInfoBlock(w);
|
||||
|
||||
w.Write(tmpPassword);
|
||||
// Add padding.
|
||||
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
||||
if (passwordPadding > 0)
|
||||
w.Write(new byte[passwordPadding]);
|
||||
|
||||
w.Write(tmpName);
|
||||
// Add padding.
|
||||
int namePadding = nameWithPadding - tmpName.Length;
|
||||
if (namePadding > 0)
|
||||
w.Write(new byte[namePadding]);
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketDealFlopCards : NetPacket
|
||||
{
|
||||
public NetPacketDealFlopCards()
|
||||
: base(NetPacket.NetTypeDealFlopCards)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketDealFlopCards(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeDealFlopCards)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketDealFlopCards invalid size.");
|
||||
Properties.Add(PropType.FlopFirstCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.FlopSecondCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.FlopThirdCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitDealFlopCards(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketDealRiverCard : NetPacket
|
||||
{
|
||||
public NetPacketDealRiverCard()
|
||||
: base(NetPacket.NetTypeDealRiverCard)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketDealRiverCard(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeDealRiverCard)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketDealRiverCard invalid size.");
|
||||
Properties.Add(PropType.RiverCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitDealRiverCard(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketDealTurnCard : NetPacket
|
||||
{
|
||||
public NetPacketDealTurnCard()
|
||||
: base(NetPacket.NetTypeDealTurnCard)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketDealTurnCard(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeDealTurnCard)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketDealTurnCard invalid size.");
|
||||
Properties.Add(PropType.TurnCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitDealTurnCard(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketEndOfGame : NetPacket
|
||||
{
|
||||
public NetPacketEndOfGame()
|
||||
: base(NetPacket.NetTypeEndOfGame)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketEndOfGame(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeEndOfGame)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketEndOfGame invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitEndOfGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketEndOfHandHideCards : NetPacket
|
||||
{
|
||||
public NetPacketEndOfHandHideCards()
|
||||
: base(NetPacket.NetTypeEndOfHandHideCards)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketEndOfHandHideCards(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeEndOfHandHideCards)
|
||||
{
|
||||
if (size != 16)
|
||||
throw new NetPacketException("NetPacketEndOfHandHideCards invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.MoneyWon,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerMoney,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitEndOfHandHideCards(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketEndOfHandShowCards : NetPacket
|
||||
{
|
||||
public NetPacketEndOfHandShowCards()
|
||||
: base(NetPacket.NetTypeEndOfHandShowCards)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketEndOfHandShowCards(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeEndOfHandShowCards)
|
||||
{
|
||||
if (size < 40)
|
||||
throw new NetPacketException("NetPacketEndOfHandShowCards invalid size.");
|
||||
int numPlayerResults = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
r.ReadUInt16(); //reserved
|
||||
|
||||
List<Dictionary<PropType, string>> tmpRecordList = new List<Dictionary<PropType, string>>();
|
||||
for (int i = 0; i < numPlayerResults; i++)
|
||||
{
|
||||
Dictionary<PropType, string> tmpList = new Dictionary<PropType, string>();
|
||||
tmpList.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.FirstCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.SecondCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos1,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos2,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos3,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos4,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
tmpList.Add(PropType.BestHandPos5,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
r.ReadUInt16(); // reserved
|
||||
tmpList.Add(PropType.CardsValue,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.MoneyWon,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
tmpList.Add(PropType.PlayerMoney,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
|
||||
tmpRecordList.Add(tmpList);
|
||||
}
|
||||
RecordProperties.Add(RecordPropType.PlayerResults, tmpRecordList);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitEndOfHandShowCards(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketError : NetPacket
|
||||
{
|
||||
public NetPacketError()
|
||||
: base(NetPacket.NetTypeError)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketError(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeError)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketError invalid size.");
|
||||
Properties.Add(PropType.ErrorReason,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitError(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
public class NetPacketException : Exception
|
||||
{
|
||||
public NetPacketException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketGameListNew : NetPacket
|
||||
{
|
||||
public NetPacketGameListNew()
|
||||
: base(NetPacket.NetTypeGameListNew)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketGameListNew(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeGameListNew)
|
||||
{
|
||||
if (size < 20)
|
||||
throw new NetPacketException("NetPacketGameListNew invalid size.");
|
||||
Properties.Add(PropType.GameId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.AdminPlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.GameMode,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
|
||||
int gameNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
|
||||
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
Properties.Add(PropType.CurNumPlayers, Convert.ToString(curNumPlayers));
|
||||
Properties.Add(PropType.GamePrivacyFlags,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
|
||||
ScanGameInfoBlock(r);
|
||||
|
||||
// Read name of the game.
|
||||
byte[] tmpName = r.ReadBytes(gameNameLen);
|
||||
Properties.Add(PropType.GameName,
|
||||
Encoding.UTF8.GetString(tmpName));
|
||||
// Skip the padding.
|
||||
int namePadding = AddPadding(tmpName.Length) - tmpName.Length;
|
||||
if (namePadding > 0)
|
||||
r.ReadBytes(namePadding);
|
||||
|
||||
// Read player ids.
|
||||
List<string> playerSlots = new List<string>();
|
||||
for (int i = 0; i < curNumPlayers; i++)
|
||||
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
ListProperties.Add(ListPropType.PlayerSlots, playerSlots);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitGameListNew(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketGameListPlayerJoined : NetPacket
|
||||
{
|
||||
public NetPacketGameListPlayerJoined()
|
||||
: base(NetPacket.NetTypeGameListPlayerJoined)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketGameListPlayerJoined(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeGameListPlayerJoined)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketGameListPlayerJoined invalid size.");
|
||||
Properties.Add(PropType.GameId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitGameListPlayerJoined(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketGameListPlayerLeft : NetPacket
|
||||
{
|
||||
public NetPacketGameListPlayerLeft()
|
||||
: base(NetPacket.NetTypeGameListPlayerLeft)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketGameListPlayerLeft(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeGameListPlayerLeft)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketGameListPlayerLeft invalid size.");
|
||||
Properties.Add(PropType.GameId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitGameListPlayerLeft(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketGameListUpdate : NetPacket
|
||||
{
|
||||
public NetPacketGameListUpdate()
|
||||
: base(NetPacket.NetTypeGameListUpdate)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketGameListUpdate(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeGameListUpdate)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketGameListUpdate invalid size.");
|
||||
Properties.Add(PropType.GameId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.GameMode,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitGameListUpdate(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketGameStart : NetPacket
|
||||
{
|
||||
public NetPacketGameStart()
|
||||
: base(NetPacket.NetTypeGameStart)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketGameStart(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeGameStart)
|
||||
{
|
||||
if (size < 20)
|
||||
throw new NetPacketException("NetPacketGameStart invalid size.");
|
||||
Properties.Add(PropType.StartDealerPlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
int curNumPlayers = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
Properties.Add(PropType.CurNumPlayers, Convert.ToString(curNumPlayers));
|
||||
r.ReadUInt16(); // reserved
|
||||
|
||||
// Read player ids.
|
||||
List<string> playerSlots = new List<string>();
|
||||
for (int i = 0; i < curNumPlayers; i++)
|
||||
playerSlots.Add(Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
ListProperties.Add(ListPropType.PlayerSlots, playerSlots);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitGameStart(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketHandStart : NetPacket
|
||||
{
|
||||
public NetPacketHandStart()
|
||||
: base(NetPacket.NetTypeHandStart)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketHandStart(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeHandStart)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketHandStart invalid size.");
|
||||
Properties.Add(PropType.FirstCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.SecondCard,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.SmallBlind,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitHandStart(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketInit : NetPacket
|
||||
{
|
||||
public NetPacketInit()
|
||||
: base(NetPacket.NetTypeInit)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitInit(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
string playerPassword = Properties[PropType.ServerPassword];
|
||||
byte[] tmpPassword = Encoding.UTF8.GetBytes(playerPassword);
|
||||
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
||||
string playerName = Properties[PropType.PlayerName];
|
||||
byte[] tmpName = Encoding.UTF8.GetBytes(playerName);
|
||||
int nameWithPadding = AddPadding(tmpName.Length);
|
||||
int size = 16 + passwordWithPadding + nameWithPadding;
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.RequestedVersionMajor])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.RequestedVersionMinor])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)playerPassword.Length));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)playerName.Length));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Privacy flags.
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
|
||||
|
||||
w.Write(tmpPassword);
|
||||
// Add padding.
|
||||
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
||||
if (passwordPadding > 0)
|
||||
w.Write(new byte[passwordPadding]);
|
||||
|
||||
w.Write(tmpName);
|
||||
// Add padding.
|
||||
int namePadding = nameWithPadding - tmpName.Length;
|
||||
if (namePadding > 0)
|
||||
w.Write(new byte[namePadding]);
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketInitAck : NetPacket
|
||||
{
|
||||
public NetPacketInitAck()
|
||||
: base(NetPacket.NetTypeInitAck)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketInitAck(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeInitAck)
|
||||
{
|
||||
if (size != 16)
|
||||
throw new NetPacketException("NetPacketInitAck invalid size.");
|
||||
Properties.Add(PropType.LatestGameVersion,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.LatestBetaRevision,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.SessionId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitInitAck(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketJoinGame : NetPacket
|
||||
{
|
||||
public NetPacketJoinGame()
|
||||
: base(NetPacket.NetTypeJoinGame)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitJoinGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
string gamePassword = Properties[PropType.GamePassword];
|
||||
byte[] tmpPassword = Encoding.UTF8.GetBytes(gamePassword);
|
||||
int passwordWithPadding = AddPadding(tmpPassword.Length);
|
||||
int size = 12 + passwordWithPadding;
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)size));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.GameId])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)gamePassword.Length));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // Reserved.
|
||||
|
||||
w.Write(tmpPassword);
|
||||
// Add padding.
|
||||
int passwordPadding = passwordWithPadding - tmpPassword.Length;
|
||||
if (passwordPadding > 0)
|
||||
w.Write(new byte[passwordPadding]);
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketJoinGameAck : NetPacket
|
||||
{
|
||||
public NetPacketJoinGameAck()
|
||||
: base(NetPacket.NetTypeJoinGameAck)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketJoinGameAck(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeJoinGameAck)
|
||||
{
|
||||
if (size < 12)
|
||||
throw new NetPacketException("NetTypeJoinGameAck invalid size.");
|
||||
Properties.Add(PropType.GameId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerRights,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
r.ReadUInt16(); // reserved
|
||||
|
||||
// Scan game info block
|
||||
ScanGameInfoBlock(r);
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitJoinGameAck(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketLeaveCurrentGame : NetPacket
|
||||
{
|
||||
public NetPacketLeaveCurrentGame()
|
||||
: base(NetPacket.NetTypeLeaveCurrentGame)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitLeaveCurrentGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)0)); // reserved
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketPlayerInfo : NetPacket
|
||||
{
|
||||
public const int PlayerFlagHuman = 0x01;
|
||||
public const int PlayerFlagAvatar = 0x02;
|
||||
|
||||
public NetPacketPlayerInfo()
|
||||
: base(NetPacket.NetTypePlayerInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketPlayerInfo(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypePlayerInfo)
|
||||
{
|
||||
if (size < 16)
|
||||
throw new NetPacketException("NetPacketPlayerInfo invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
int playerFlags = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
Properties.Add(PropType.PlayerFlags, Convert.ToString(playerFlags));
|
||||
int playerNameLen = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
r.ReadUInt32(); // reserved
|
||||
if ((playerFlags & PlayerFlagAvatar) == PlayerFlagAvatar)
|
||||
r.ReadBytes(16); // Skip avatar md5.
|
||||
|
||||
byte[] tmpName = r.ReadBytes(playerNameLen);
|
||||
Properties.Add(PropType.PlayerName,
|
||||
Encoding.UTF8.GetString(tmpName));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitPlayerInfo(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketPlayersAction : NetPacket
|
||||
{
|
||||
public NetPacketPlayersAction()
|
||||
: base(NetPacket.NetTypePlayersAction)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitPlayersAction(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)12));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.GameState])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.PlayerAction])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.PlayerBet])));
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketPlayersActionDone : NetPacket
|
||||
{
|
||||
public NetPacketPlayersActionDone()
|
||||
: base(NetPacket.NetTypePlayersActionDone)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketPlayersActionDone(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypePlayersActionDone)
|
||||
{
|
||||
if (size != 28)
|
||||
throw new NetPacketException("NetPacketPlayersActionDone invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.GameState,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.PlayerAction,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.PlayerBetTotal,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.PlayerMoney,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.HighestSet,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.MinimumRaise,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitPlayersActionDone(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketPlayersActionRejected : NetPacket
|
||||
{
|
||||
public NetPacketPlayersActionRejected()
|
||||
: base(NetPacket.NetTypePlayersActionRejected)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketPlayersActionRejected(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypePlayersActionRejected)
|
||||
{
|
||||
if (size != 16)
|
||||
throw new NetPacketException("NetPacketPlayersActionRejected invalid size.");
|
||||
Properties.Add(PropType.GameState,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.PlayerAction,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
Properties.Add(PropType.PlayerBet,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.ActionRejectReason,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitPlayersActionRejected(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketPlayersTurn : NetPacket
|
||||
{
|
||||
public NetPacketPlayersTurn()
|
||||
: base(NetPacket.NetTypePlayersTurn)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketPlayersTurn(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypePlayersTurn)
|
||||
{
|
||||
if (size != 12)
|
||||
throw new NetPacketException("NetPacketPlayersTurn invalid size.");
|
||||
Properties.Add(PropType.PlayerId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.GameState,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitPlayersTurn(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketRemovedFromGame : NetPacket
|
||||
{
|
||||
public NetPacketRemovedFromGame()
|
||||
: base(NetPacket.NetTypeRemovedFromGame)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketRemovedFromGame(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeRemovedFromGame)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketRemovedFromGame invalid size.");
|
||||
Properties.Add(PropType.RemoveReason,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitRemovedFromGame(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketRetrieveAvatar : NetPacket
|
||||
{
|
||||
public NetPacketRetrieveAvatar()
|
||||
: base(NetPacket.NetTypeRetrieveAvatar)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketRetrieveAvatar(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeRetrieveAvatar)
|
||||
{
|
||||
if (size != 24)
|
||||
throw new NetPacketException("NetTypeRetrieveAvatar invalid size.");
|
||||
Properties.Add(PropType.RequestId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
Properties.Add(PropType.AvatarMD5,
|
||||
Convert.ToBase64String(r.ReadBytes(16)));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitRetrieveAvatar(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)24));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.RequestId])));
|
||||
w.Write(Convert.FromBase64String(Properties[PropType.AvatarMD5]));
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketRetrievePlayerInfo : NetPacket
|
||||
{
|
||||
public NetPacketRetrievePlayerInfo()
|
||||
: base(NetPacket.NetTypeRetrievePlayerInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitRetrievePlayerInfo(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)
|
||||
Convert.ToUInt32(Properties[PropType.PlayerId])));
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketStartEvent : NetPacket
|
||||
{
|
||||
public NetPacketStartEvent()
|
||||
: base(NetPacket.NetTypeStartEvent)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketStartEvent(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeStartEvent)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetTypeStartEvent invalid size.");
|
||||
Properties.Add(PropType.StartFlags,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((short)r.ReadUInt16())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitStartEvent(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)
|
||||
Convert.ToUInt16(Properties[PropType.StartFlags])));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)0)); // reserved
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketStartEventAck : NetPacket
|
||||
{
|
||||
public NetPacketStartEventAck()
|
||||
: base(NetPacket.NetTypeStartEventAck)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitStartEventAck(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)0)); // reserved
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketUnknownAvatar : NetPacket
|
||||
{
|
||||
public NetPacketUnknownAvatar()
|
||||
: base(NetPacket.NetTypeUnknownAvatar)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketUnknownAvatar(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeUnknownAvatar)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketUnknownAvatar invalid size.");
|
||||
Properties.Add(PropType.RequestId,
|
||||
Convert.ToString(IPAddress.NetworkToHostOrder((int)r.ReadUInt32())));
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitUnknownAvatar(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetPacketUnsubscribeGameList : NetPacket
|
||||
{
|
||||
public NetPacketUnsubscribeGameList()
|
||||
: base(NetPacket.NetTypeUnsubscribeGameList)
|
||||
{
|
||||
}
|
||||
|
||||
public NetPacketUnsubscribeGameList(int size, BinaryReader r)
|
||||
: base(NetPacket.NetTypeUnsubscribeGameList)
|
||||
{
|
||||
if (size != 8)
|
||||
throw new NetPacketException("NetPacketUnsubscribeGameList invalid size.");
|
||||
}
|
||||
|
||||
public override void Accept(INetPacketVisitor visitor)
|
||||
{
|
||||
visitor.VisitJoinGameAck(this);
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream();
|
||||
BinaryWriter w = new BinaryWriter(memStream);
|
||||
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)Type));
|
||||
w.Write(IPAddress.HostToNetworkOrder((short)8));
|
||||
w.Write(IPAddress.HostToNetworkOrder((int)0)); // reserved
|
||||
|
||||
return memStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,455 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class NetParser : INetPacketVisitor
|
||||
{
|
||||
public NetParser(PokerTHData data, SenderThread sender, ICallback callback)
|
||||
{
|
||||
m_data = data;
|
||||
m_sender = sender;
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
public void VisitInit(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitInitAck(NetPacket p)
|
||||
{
|
||||
m_data.MyPlayerId =
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
// Add self to list.
|
||||
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||
m_data.MyPlayerId,
|
||||
m_data.MyName));
|
||||
m_callback.InitDone();
|
||||
}
|
||||
|
||||
public void VisitGameListNew(NetPacket p)
|
||||
{
|
||||
// Add game to list.
|
||||
m_data.GameList.AddGameInfo(new GameInfo(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]),
|
||||
p.Properties[NetPacket.PropType.GameName],
|
||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]),
|
||||
p.ListProperties[NetPacket.ListPropType.PlayerSlots].
|
||||
ConvertAll<uint>(Convert.ToUInt32),
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.StartMoney]),
|
||||
Convert.ToUInt16(p.Properties[NetPacket.PropType.GamePrivacyFlags]) == 1));
|
||||
}
|
||||
|
||||
public void VisitGameListUpdate(NetPacket p)
|
||||
{
|
||||
GameInfo.Mode mode =
|
||||
(GameInfo.Mode)Convert.ToInt32(p.Properties[NetPacket.PropType.GameMode]);
|
||||
uint id = Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
||||
if (mode == GameInfo.Mode.Closed) // Remove game if it is has been closed.
|
||||
m_data.GameList.RemoveGameInfo(id);
|
||||
else
|
||||
m_data.GameList.GetGameInfo(id).CurrentMode = mode;
|
||||
}
|
||||
|
||||
public void VisitGameListPlayerJoined(NetPacket p)
|
||||
{
|
||||
GameInfo info = m_data.GameList.GetGameInfo(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]));
|
||||
List<uint> playerSlots = info.PlayerSlots;
|
||||
playerSlots.Add(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]));
|
||||
info.PlayerSlots = playerSlots;
|
||||
}
|
||||
|
||||
public void VisitGameListPlayerLeft(NetPacket p)
|
||||
{
|
||||
GameInfo info = m_data.GameList.GetGameInfo(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]));
|
||||
List<uint> playerSlots = info.PlayerSlots;
|
||||
playerSlots.Remove(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]));
|
||||
info.PlayerSlots = playerSlots;
|
||||
}
|
||||
|
||||
public void VisitRetrievePlayerInfo(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitPlayerInfo(NetPacket p)
|
||||
{
|
||||
// Add player to list.
|
||||
m_data.PlayerList.AddPlayerInfo(new PlayerInfo(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]),
|
||||
p.Properties[NetPacket.PropType.PlayerName]));
|
||||
}
|
||||
|
||||
public void VisitCreateGame(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitJoinGame(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitJoinGameAck(NetPacket p)
|
||||
{
|
||||
m_data.MyGameId =
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.GameId]);
|
||||
m_callback.JoinedGame(m_data.GameList.GetGameInfo(m_data.MyGameId).Name);
|
||||
m_data.JoinedGame = true;
|
||||
}
|
||||
|
||||
public void VisitLeaveCurrentGame(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitStartEvent(NetPacket p)
|
||||
{
|
||||
// Request player names for player ids.
|
||||
List<uint> playerSlots = m_data.GameList.GetGameInfo(m_data.MyGameId).PlayerSlots;
|
||||
foreach (uint id in playerSlots)
|
||||
{
|
||||
if (!m_data.PlayerList.HasPlayer(id))
|
||||
{
|
||||
NetPacketRetrievePlayerInfo request = new NetPacketRetrievePlayerInfo();
|
||||
request.Properties.Add(NetPacket.PropType.PlayerId, Convert.ToString(id));
|
||||
m_sender.Send(request);
|
||||
}
|
||||
}
|
||||
// Acknowledge start event.
|
||||
NetPacketStartEventAck ack = new NetPacketStartEventAck();
|
||||
m_sender.Send(ack);
|
||||
}
|
||||
|
||||
public void VisitStartEventAck(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitGameStart(NetPacket p)
|
||||
{
|
||||
// Generate player list, for gui and as hand data.
|
||||
List<string> strPlayers = new List<string>();
|
||||
|
||||
List<uint> slots = p.ListProperties[NetPacket.ListPropType.PlayerSlots].
|
||||
ConvertAll<uint>(Convert.ToUInt32);
|
||||
m_players = new Dictionary<uint, Player>();
|
||||
|
||||
foreach (uint i in slots)
|
||||
{
|
||||
if (m_data.PlayerList.HasPlayer(i))
|
||||
strPlayers.Add(m_data.PlayerList.GetPlayerInfo(i).Name);
|
||||
else
|
||||
strPlayers.Add(Convert.ToString(i));
|
||||
// Set player data.
|
||||
Player tmpPlayer = new Player();
|
||||
tmpPlayer.Money = m_data.GameList.GetGameInfo(m_data.MyGameId).StartMoney;
|
||||
m_players.Add(i, tmpPlayer);
|
||||
}
|
||||
|
||||
m_callback.GameStarted(strPlayers);
|
||||
}
|
||||
|
||||
public void VisitHandStart(NetPacket p)
|
||||
{
|
||||
// Reset players.
|
||||
foreach (KeyValuePair<uint, Player> player in m_players)
|
||||
player.Value.NewHand();
|
||||
|
||||
// Assign own cards.
|
||||
int[] tmpCards = new int[2];
|
||||
tmpCards[0] =
|
||||
Convert.ToInt32(p.Properties[NetPacket.PropType.FirstCard]);
|
||||
tmpCards[1] =
|
||||
Convert.ToInt32(p.Properties[NetPacket.PropType.SecondCard]);
|
||||
m_players[m_data.MyPlayerId].Cards = tmpCards;
|
||||
|
||||
m_data.CurHand = new Hand(
|
||||
m_players,
|
||||
m_data.MyPlayerId,
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.SmallBlind]));
|
||||
m_callback.HandStarted(tmpCards);
|
||||
}
|
||||
|
||||
public void VisitPlayersTurn(NetPacket p)
|
||||
{
|
||||
uint curPlayer = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
Hand.State state = (Hand.State)Convert.ToUInt16(p.Properties[NetPacket.PropType.GameState]);
|
||||
if (curPlayer == m_data.MyPlayerId)
|
||||
m_callback.MyTurn(state, m_data.CurHand.HighestSet,
|
||||
m_data.CurHand.MinimumRaise, m_players[curPlayer].Money);
|
||||
else
|
||||
m_callback.PlayersTurn(state, m_data.PlayerList.GetPlayerInfo(curPlayer).Name);
|
||||
}
|
||||
|
||||
public void VisitPlayersAction(NetPacket p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void VisitPlayersActionDone(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
curPlayer.CurAction =
|
||||
(Hand.Action)Convert.ToUInt16(p.Properties[NetPacket.PropType.PlayerAction]);
|
||||
curPlayer.Money =
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerMoney]);
|
||||
uint curBet = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerBetTotal])
|
||||
- curPlayer.TotalBet;
|
||||
curPlayer.TotalBet += curBet;
|
||||
|
||||
m_data.CurHand.HighestSet = Convert.ToUInt32(p.Properties[NetPacket.PropType.HighestSet]);
|
||||
m_data.CurHand.MinimumRaise = Convert.ToUInt32(p.Properties[NetPacket.PropType.MinimumRaise]);
|
||||
|
||||
if (curPlayer.CurAction == Hand.Action.None)
|
||||
{
|
||||
if (curBet == m_data.CurHand.SmallBlind)
|
||||
m_callback.SmallBlind(name, curBet);
|
||||
else
|
||||
m_callback.BigBlind(name, curBet);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect non-fold players.
|
||||
List<string> nonFoldPlayers = new List<string>();
|
||||
foreach (KeyValuePair<uint, Player> player in m_players)
|
||||
{
|
||||
if (player.Value.CurAction != Hand.Action.Fold)
|
||||
nonFoldPlayers.Add(m_data.PlayerList.GetPlayerInfo(player.Key).Name);
|
||||
}
|
||||
// Inform about action.
|
||||
m_callback.ActionDone(
|
||||
name,
|
||||
curPlayer.CurAction,
|
||||
curBet,
|
||||
curPlayer.Money,
|
||||
nonFoldPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
public void VisitPlayersActionRejected(NetPacket p)
|
||||
{
|
||||
m_callback.ActionRejected();
|
||||
}
|
||||
|
||||
public void VisitDealFlopCards(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.Flop;
|
||||
int[] tmpCards = new int[3];
|
||||
tmpCards[0] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopFirstCard]);
|
||||
tmpCards[1] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopSecondCard]);
|
||||
tmpCards[2] = Convert.ToInt32(p.Properties[NetPacket.PropType.FlopThirdCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowFlopCards(tmpCards);
|
||||
}
|
||||
|
||||
public void VisitDealTurnCard(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.Turn;
|
||||
int[] tmpCards = new int[4];
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[3] = Convert.ToInt32(p.Properties[NetPacket.PropType.TurnCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowTurnCards(tmpCards);
|
||||
}
|
||||
|
||||
public void VisitDealRiverCard(NetPacket p)
|
||||
{
|
||||
m_data.CurHand.CurState = Hand.State.River;
|
||||
int[] tmpCards = new int[5];
|
||||
m_data.CurHand.TableCards.CopyTo(tmpCards, 0);
|
||||
tmpCards[4] = Convert.ToInt32(p.Properties[NetPacket.PropType.RiverCard]);
|
||||
m_data.CurHand.TableCards = tmpCards;
|
||||
m_callback.ShowPot(m_data.CurHand.Pot);
|
||||
m_callback.ShowRiverCards(tmpCards);
|
||||
}
|
||||
|
||||
public void VisitAllInShowCards(NetPacket p)
|
||||
{
|
||||
List<Dictionary<NetPacket.PropType, string>> tmpList
|
||||
= p.RecordProperties[NetPacket.RecordPropType.PlayerCards];
|
||||
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||
int[] tmpCards = new int[2];
|
||||
tmpCards[0] = Convert.ToInt32(i[NetPacket.PropType.FirstCard]);
|
||||
tmpCards[1] = Convert.ToInt32(i[NetPacket.PropType.SecondCard]);
|
||||
curPlayer.Cards = tmpCards;
|
||||
|
||||
m_callback.ShowCards(name, tmpCards);
|
||||
}
|
||||
}
|
||||
|
||||
public void VisitEndOfHandShowCards(NetPacket p)
|
||||
{
|
||||
List<Dictionary<NetPacket.PropType, string>> tmpList
|
||||
= p.RecordProperties[NetPacket.RecordPropType.PlayerResults];
|
||||
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||
int[] tmpCards = new int[2];
|
||||
tmpCards[0] = Convert.ToInt32(i[NetPacket.PropType.FirstCard]);
|
||||
tmpCards[1] = Convert.ToInt32(i[NetPacket.PropType.SecondCard]);
|
||||
curPlayer.Cards = tmpCards;
|
||||
int[] tmpBest = new int[5];
|
||||
tmpBest[0] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos1]);
|
||||
tmpBest[1] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos2]);
|
||||
tmpBest[2] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos3]);
|
||||
tmpBest[3] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos4]);
|
||||
tmpBest[4] = Convert.ToInt32(i[NetPacket.PropType.BestHandPos5]);
|
||||
curPlayer.BestHandPos = tmpBest;
|
||||
curPlayer.CardsValue = Convert.ToInt32(i[NetPacket.PropType.CardsValue]);
|
||||
curPlayer.Money = Convert.ToUInt32(i[NetPacket.PropType.PlayerMoney]);
|
||||
|
||||
m_callback.EndOfHandShowCards(name, tmpCards, curPlayer.CardsValue, false);
|
||||
}
|
||||
m_callback.HandResult();
|
||||
foreach (Dictionary<NetPacket.PropType, string> i in tmpList)
|
||||
{
|
||||
uint moneyWon = Convert.ToUInt32(i[NetPacket.PropType.MoneyWon]);
|
||||
if (moneyWon > 0)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(i[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
m_callback.PlayerWinsHand(name, moneyWon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void VisitEndOfHandHideCards(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
Player curPlayer = m_data.CurHand.Players[playerId];
|
||||
curPlayer.Money = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerMoney]);
|
||||
|
||||
m_callback.HandResult();
|
||||
m_callback.PlayerWinsHand(
|
||||
name,
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.MoneyWon]));
|
||||
}
|
||||
|
||||
public void VisitEndOfGame(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
string name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
|
||||
m_callback.PlayerWinsGame(name);
|
||||
|
||||
NetPacket leave = new NetPacketLeaveCurrentGame();
|
||||
m_sender.Send(leave);
|
||||
m_data.JoinedGame = false;
|
||||
}
|
||||
|
||||
public void VisitRemovedFromGame(NetPacket p)
|
||||
{
|
||||
m_callback.RemovedFromGame();
|
||||
}
|
||||
|
||||
public void VisitChatText(NetPacket p)
|
||||
{
|
||||
uint playerId = Convert.ToUInt32(p.Properties[NetPacket.PropType.PlayerId]);
|
||||
string name;
|
||||
if (playerId == 0)
|
||||
name = "(global notice)";
|
||||
else
|
||||
name = m_data.PlayerList.GetPlayerInfo(playerId).Name;
|
||||
|
||||
m_callback.ChatText(
|
||||
name,
|
||||
p.Properties[NetPacket.PropType.ChatText]);
|
||||
}
|
||||
|
||||
public void VisitError(NetPacket p)
|
||||
{
|
||||
m_callback.Error(p.Properties[NetPacket.PropType.ErrorReason]);
|
||||
}
|
||||
|
||||
public void VisitRetrieveAvatar(NetPacket p)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void VisitAvatarHeader(NetPacket p)
|
||||
{
|
||||
uint tmpAvatarType = Convert.ToUInt32(p.Properties[NetPacket.PropType.AvatarFileType]);
|
||||
GameInfo.AvatarFileType avatarType;
|
||||
switch (tmpAvatarType)
|
||||
{
|
||||
case 1 :
|
||||
avatarType = GameInfo.AvatarFileType.PNG;
|
||||
break;
|
||||
case 2 :
|
||||
avatarType = GameInfo.AvatarFileType.JPG;
|
||||
break;
|
||||
case 3 :
|
||||
avatarType = GameInfo.AvatarFileType.GIF;
|
||||
break;
|
||||
default :
|
||||
avatarType = GameInfo.AvatarFileType.UNKNOWN;
|
||||
break;
|
||||
|
||||
}
|
||||
m_callback.AvatarBegin(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.RequestId]),
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.AvatarFileSize]),
|
||||
avatarType);
|
||||
}
|
||||
|
||||
public void VisitAvatarFile(NetPacket p)
|
||||
{
|
||||
m_callback.AvatarData(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.RequestId]),
|
||||
Convert.FromBase64String(p.Properties[NetPacket.PropType.AvatarFileData]));
|
||||
}
|
||||
|
||||
public void VisitAvatarEnd(NetPacket p)
|
||||
{
|
||||
m_callback.AvatarEnd(
|
||||
Convert.ToUInt32(p.Properties[NetPacket.PropType.RequestId]));
|
||||
}
|
||||
|
||||
public void VisitUnknownAvatar(NetPacket p)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
private PokerTHData m_data;
|
||||
private SenderThread m_sender;
|
||||
private ICallback m_callback;
|
||||
private Dictionary<uint, Player> m_players;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
abstract class NetThread : BasicThread
|
||||
{
|
||||
public NetThread(NetworkStream stream)
|
||||
: base()
|
||||
{
|
||||
m_netStream = stream;
|
||||
}
|
||||
|
||||
protected NetworkStream NetStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_netStream;
|
||||
}
|
||||
}
|
||||
|
||||
private NetworkStream m_netStream;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class ReceiverThread : NetThread
|
||||
{
|
||||
const uint MaxPacketSize = 268;
|
||||
const uint MinPacketSize = 8;
|
||||
|
||||
public ReceiverThread(NetworkStream stream, SenderThread sender, PokerTHData data, ICallback callback)
|
||||
: base(stream)
|
||||
{
|
||||
m_recBuf = new byte[8192];
|
||||
m_recBufOffset = 0;
|
||||
m_packetList = new List<NetPacket>();
|
||||
m_sender = sender;
|
||||
m_parser = new NetParser(data, sender, callback);
|
||||
}
|
||||
|
||||
protected override void Main()
|
||||
{
|
||||
while (!IsTerminateFlagSet())
|
||||
{
|
||||
ReadFromStream();
|
||||
ScanPackets();
|
||||
ParsePackets();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ReadFromStream()
|
||||
{
|
||||
if (NetStream.DataAvailable)
|
||||
m_recBufOffset += NetStream.Read(m_recBuf, m_recBufOffset, m_recBuf.Length - m_recBufOffset);
|
||||
else
|
||||
Thread.Sleep(15);
|
||||
}
|
||||
|
||||
protected void ScanPackets()
|
||||
{
|
||||
bool packetFound;
|
||||
|
||||
do
|
||||
{
|
||||
packetFound = false;
|
||||
if (m_recBufOffset >= MinPacketSize)
|
||||
{
|
||||
// Treat input buffer as memory stream.
|
||||
MemoryStream memStream = new MemoryStream(m_recBuf);
|
||||
BinaryReader r = new BinaryReader(memStream);
|
||||
int type = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
int size = IPAddress.NetworkToHostOrder((short)r.ReadUInt16());
|
||||
if (m_recBufOffset >= size)
|
||||
{
|
||||
packetFound = true;
|
||||
if (size > MaxPacketSize)
|
||||
{
|
||||
// Ignore packets which are too long.
|
||||
m_recBufOffset -= size;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Scan Packet.
|
||||
NetPacket packet = NetPacket.Create(type, size, r);
|
||||
if (packet != null)
|
||||
m_packetList.Add(packet);
|
||||
// Advance within buf.
|
||||
if (m_recBufOffset > size)
|
||||
{
|
||||
for (int i = size, j = 0; i < m_recBufOffset; i++, j++)
|
||||
{
|
||||
m_recBuf[j] = m_recBuf[i];
|
||||
}
|
||||
m_recBufOffset -= size;
|
||||
}
|
||||
else
|
||||
m_recBufOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (packetFound);
|
||||
}
|
||||
|
||||
protected void ParsePackets()
|
||||
{
|
||||
foreach (NetPacket p in m_packetList)
|
||||
{
|
||||
p.Accept(m_parser);
|
||||
}
|
||||
m_packetList.Clear();
|
||||
}
|
||||
|
||||
private byte[] m_recBuf;
|
||||
private int m_recBufOffset;
|
||||
private List<NetPacket> m_packetList;
|
||||
private SenderThread m_sender;
|
||||
private NetParser m_parser;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Lothar May *
|
||||
* *
|
||||
* This file is part of pokerth_console. *
|
||||
* pokerth_console is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Affero General Public License *
|
||||
* as published by the Free Software Foundation, either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* pokerth_console 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 Affero General Public License along with pokerth_console. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace pokerth_lib
|
||||
{
|
||||
class SenderThread : NetThread
|
||||
{
|
||||
public SenderThread(NetworkStream stream)
|
||||
: base(stream)
|
||||
{
|
||||
m_packetQueue = new Queue<NetPacket>();
|
||||
}
|
||||
|
||||
public void Send(NetPacket p)
|
||||
{
|
||||
lock (m_packetQueue)
|
||||
{
|
||||
m_packetQueue.Enqueue(p);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Main()
|
||||
{
|
||||
while (!IsTerminateFlagSet())
|
||||
{
|
||||
bool sleep = false;
|
||||
lock (m_packetQueue)
|
||||
{
|
||||
if (m_packetQueue.Count > 0)
|
||||
{
|
||||
byte[] outBuf = m_packetQueue.Dequeue().ToByteArray();
|
||||
NetStream.Write(outBuf, 0, outBuf.Length);
|
||||
}
|
||||
else
|
||||
sleep = true;
|
||||
}
|
||||
if (sleep)
|
||||
Thread.Sleep(15);
|
||||
}
|
||||
}
|
||||
|
||||
private Queue<NetPacket> m_packetQueue;
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
Copyright (c) 2006-2007, ComponentAce
|
||||
http://www.componentace.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user