diff --git a/create-release.sh b/create-release.sh new file mode 100755 index 00000000..bdc4333a --- /dev/null +++ b/create-release.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +rm regression-test/*.found.txt +rm regression-test/*.pyc +rm pyfpdb/*.pyc + +mkdir fpdb-$1 +cp -R docs fpdb-$1/ +cp -R packaging fpdb-$1/ +cp -R pyfpdb fpdb-$1/ +rm fpdb-$1/pyfpdb/HUD_config.* +cp pyfpdb/HUD_config.xml.example fpdb-$1/pyfpdb/HUD_config.xml +cp -R regression-test fpdb-$1/ +cp -R utils fpdb-$1/ + +cd fpdb-$1 +zip -r ../../fpdb-1.0_$1.zip * +tar -cf - * | bzip2 >> ../../fpdb-1.0_$1.tar.bz2 +cd .. +rm -r fpdb-$1 + +echo "Please ensure the files are named fpdb-1.0_alpha*_p*.*" diff --git a/docs/abbreviations.txt b/docs/abbreviations.txt new file mode 100644 index 00000000..94fd5b16 --- /dev/null +++ b/docs/abbreviations.txt @@ -0,0 +1,47 @@ +HUD/table viewer +================ +A3-7=3rd-7th street Complete/Raise percentage +AF=Flop Bet/Raise percentage +AT=River Bet/Raise percentage +AR=Turn Bet/Raise percentage +F3-7=3rd-7th street Fold percentage +FB=like FSB but for big blinds only +FF=Flop Fold percentage +FR=River Fold percentage +FSB=Fold to steal - combined of small and big blind (FSB means Fold Small Big). E.g. if a player faced a steal attempt in the SB 7 times and +FS=like FSB but for small blinds only. +FT=Turn Fold percentage +HD=Hands +PF3B4B=Pre Flop 3Bet or 4Bet +PFR=Pre Flop Raise +Postf A=Postflop (ie. flop+turn+river) Aggression% +Postf F=Postflop Fold % +SD/F=Showdown/Flop=WtSD=How often player went to showdown when he saw the flop +ST=Steal chance (nobody had entered the pot before the player in question, and the player is in cutoff, button or SB position) +W$wsF=Won $ when he saw flop +W$@SD=Won $ at showdown +VPI3=Voluntary Put In on 3rd Street (ie. call+complete+raise) +VPIP=Voluntary Put In Preflop (ie. call+raise) + +Other +===== +CLI=Command Line Interface (Shell, Terminal, "DOS-window") +FTP=Full Tilt Poker +GUI=Graphical User Interface (normal interface with buttons and menus) +HUD=Heads-Up Display (shows stats directly in the poker software) +PS=PokerStars +MTT=Multi Table Tournament +SnG=Sit and Go + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/agpl-3.0.txt b/docs/agpl-3.0.txt new file mode 100644 index 00000000..dba13ed2 --- /dev/null +++ b/docs/agpl-3.0.txt @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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 +. diff --git a/docs/benchmarks.txt b/docs/benchmarks.txt new file mode 100644 index 00000000..9f3bc680 --- /dev/null +++ b/docs/benchmarks.txt @@ -0,0 +1,75 @@ +benchmarks +========== +All measurements on my Athlon64@1.1GHz, 1 GB RAM, RAID5, Hardened Gentoo Linux 2.6.23 +From svn47 all measurements on my Athlon64 X2@1GHz, 2GB RAM +All measurements were ran several times in a row, unless otherwise noted the computer was mostly idle +svn12/15 were with PostgreSQL, svn23 onwards with MySQL +All import measurements were taken immediately after reseting the tables + +svn12, whilst compiling open office in the background +===== +reseting tables (incl filling default data): 0.5-0.6s +importing one hand from a file: 0.5-0.7s + +svn15 +===== +reseting tables (incl filling default data): 0.35-0.4s +importing one FTP hand from a file: 0.2-0.3s or 12-18k/hr +importing 51 FTP hands: 2.8-2.9s or 63-66k/hr +The large speedup will be partially due to not compiling in the background, and +partially due to less connecting/disconnecting the DB I'd imagine. +I'm VERY happy with this performance, but large gains could probably be made by +making the importer just a bit more sensible. + +svn23 +===== +reseting tables (incl filling default data): 0.3-0.35s +importing 75 PS hands: 3.2s or 84k/hr +importing 180 FTP hands: 7.7-7.9s 82k/hr +This is the rewrite in import_FTP_and_PS.py, svn12/15 are with import_file.py +Nice, it's substantially faster inspite of supporting PS and FTP (ish) rather +than just FTP and handling more special cases. + +svn24 +===== +importing 75 PS hands: 3.2-3.3s or 82k/hr +importing 507 FTP hands: 23.5-23.8s or 77k/hr +importing 947 FTP hands: 76.2-72.7s or 44k/hr +As you can see FTP has gotten about 6% slower on 500 hands - but the much expanded handling +of new cases (particularly the ante folding will be ALOT of extra string +comparisons) easily explains that. In fact I expected a much bigger impact. + (I suspect this is due to the parsing pausing whilst my shell catches up) + +svn47 +===== +It significantly slows down as the database gets larger, after a few thousand +hands it got to just one hand per second and slower. However, around 90% of the +CPU load was MySQL. Any tips are most welcome.. + +svn52 (whilst watching movie in a small window) +===== +Importing 2500 hands (mixed sites+types): 6m15s or 31k/hr (ran twice) +Of these 230 were skipped as duplicate or partial so counting 2270 hands + +svn53 (whilst watching movie in a small window) +===== +Importing the 2270 hands from svn52: 1m50 or 74k/hr (82 if counting dupes/partial) +Importing my 35661 (plus 427 dupe/part) hands: 51m51s or 41k/hr (ran once) + +The dbsize still has a significant impact, but with these sizes certainly it's +just not a problem. If anyone runs a larger database let me know how long it takes. +Thanks bwarycha for the tip with the foreign keys! + + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/codingstyle.txt b/docs/codingstyle.txt new file mode 100644 index 00000000..31c113f9 --- /dev/null +++ b/docs/codingstyle.txt @@ -0,0 +1,27 @@ +This is just a loose collection of things so far, but might as well make a start :) + +A word on wrapping: Please avoid making manual line breaks, the computer can and therefore should do it. Whether people use a phone or a 40" super-uber-HD screen, they should be allowed to use as much of it as they wish/can. Incidentially, if anyone knows how to activate line wrap in Eclipse I'd really appreciate if you let me know. + +Comments (or prints) with todo are things that are missing, bugs, or just messy code. + +After every def (ie. at the end of the method) there should be a comment including the name, e.g. +#def end of parseActionLine + +If you don't mind make names in java style, ie.: +Classes, files or tables like this: MyClassName +Methods and variables like this: myMethodName + +I'll eventually change all my code to that style, too. + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/db-todo.txt b/docs/db-todo.txt new file mode 100644 index 00000000..9d8c0042 --- /dev/null +++ b/docs/db-todo.txt @@ -0,0 +1,22 @@ +stats to add +============ +*CC,TotalColdCalls,TimesFacingRaisePreflop +**Folded to 3-Bet,FoldedToThreeBetPreflop,FacedThreeBetPreflop +Called 3-Bet,CalledThreeBetPreflop,FacedThreeBetPreflop +*Winning %,wonhand,TotalHands +**Flop Aggression Factor,timesaggressiveflop,timescalledflop +**Turn Aggression Factor,timesaggressiveturn,timescalledturn +**River Aggression Factor,timesaggressiveriver,timescalledriver +scoopedPot (useful for hi/lo split games) + +couldSqueeze, didSqueeze, facedSqueeze, calledSqueeze -> if (player raises from EP) and (someone after him calls) and (someone after that goes all in) +Donk Bet Turn,DidDonkBetTurn,CouldDonkBetTurn -> EP raises, LP reraises, EP calls. If EP bets out after the flop, it is considered a donk bet +Float Turn,DidFloatTurn,CouldFloatTurn -> + +other +===== +look at PT3 and HM tables see if i forgot anything +store all-in somewhere +add somewhere: mixed flag to denote that the game is part of a mixed game rotation + +add tables for single draw (5card draw, 2-7 single draw, badugi) and tripple draw (2-7 tripple draw) diff --git a/docs/fdl-1.2.txt b/docs/fdl-1.2.txt new file mode 100644 index 00000000..4a0fe1c8 --- /dev/null +++ b/docs/fdl-1.2.txt @@ -0,0 +1,397 @@ + GNU Free Documentation License + Version 1.2, November 2002 + + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation 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. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff --git a/docs/filelist.txt b/docs/filelist.txt new file mode 100644 index 00000000..15e9361a --- /dev/null +++ b/docs/filelist.txt @@ -0,0 +1,75 @@ +This is partially outdated + +File list +========= +.: +docs/ Documentation files +pyfpdb/ The main program (in python) +setup/ Directory with files for setting up this program +regression-test/ Directory with test data, query scripts (in python) and the regression test script (in bash) +utils/ A couple of things that will migrate to the main prog soon +viewer/ Directory with the GUI (in Java) + +./docs: +abbreviations.txt A list of abbreviations used and their meaning +agpl-3.0.txt License of the program (everything under /code) +benchmarks.txt Some benchmark results +codingstyle.txt Some notes on formatting. Feel free to ignore. +fdl-1.2.txt License of the documentation (the files in /) +filelist.txt This file +howto-import.txt Instructions on how to run the importer +install-in-gentoo.txt Installation instructions for Gentoo GNU/Linux +install-in-windows.txt Installation instructions for Windows +readme-dev.txt Some notes, pointers and such for developers or anyone else interested in changing fpdb +readme-overview.txt Some general info about this program - read that first +readme-user.txt Instructions on how to use fpdb +status.txt Details of support for poker types and sites +tabledesign.html Table design with comments + +./pyfpdb: +fpdb.py The main GUI. This is what the user will start and use to access the other things. +fpdb_import.py Main import program. Calls methods in the other files. + Takes one hand history file as input. This is the file + you execute, do not run the other ones individually. + Except import_gui.py of course. +fpdb_parse_logic.py Parses a holdem/omaha/razz/stud hand. +fpdb_save_to_db.py Just methods to store the parsed data into SQL. + Seperate file because these calls are very unwieldy. +fpdb_simple.py Simple methods called by the other files. Most work is + actually done in this file to make the other ones look + much easier than they are. +import_gui.py GUI interface to the importer (obselete) + +./setup: +insert-basedata.sql Fills sites and gametypes tables. Run this once after running the above. +recreate-tables.sql File for mysql to recreate the tables. THIS WILL DELETE EXISTING TABLES!!! + +./testdata: +should be self explanatory + +./utils: +dump_db_basedata.py Prints the contents of the tables sites and gametypes +fpdb_util_lib.py Helper methods for the utilities. +get_DB_stats.py Prints some counts (like no. of players in the DB) +get_player_stats.py Prints certain stats about players with CLI-passed constraints +mysql-reset-tables.sh Reset tables for MySQL. THIS WILL DELETE EXISTING TABLES!!! +print_hand.py Prints a hand in legible format. +psql-interactive.sh *nix script to connect to a PostgreSQL database in + interactive mode (note that we're currently only supporting MySQL) +regression-test.sh Resets tables and checks manually verified hands for errors + +./viewer: +todo + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/install-in-ubuntu.txt b/docs/install-in-ubuntu.txt new file mode 100644 index 00000000..b3843eca --- /dev/null +++ b/docs/install-in-ubuntu.txt @@ -0,0 +1,46 @@ +Last checked: 1 Sep, p74 + +These instructions are for any Ubuntu Linux, but except for the name of the package management software it should be identical on other Linux distributions. + +Using the package manager (I think it's called synaptics) install the dependencies: mysql, python, mysql-python, pygtk +I don't use ubuntu but I'd imagine it will at some point prompt you for a MySQL root password enter one and when it's done installing everything open a shell/terminal and type this: +mysql --user=root --password=YourMysqlRootPassword +It should say something like this: + +Welcome to the MySQL monitor. Commands end with ; or \g. +Your MySQL connection id is 4 +Server version: 5.0.60-log Ubuntu Linux mysql-5.0.60-r1 + +Type 'help;' or '\h' for help. Type '\c' to clear the buffer. + +mysql> + +Now type this: +CREATE DATABASE fpdb; + +Next you need to create a user. Type this (replacing newPassword with the password you want the fpdb user to have - this can, but for security shouldn't, be the same as the root mysql password): +GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION; + +Then download one of the alpha2 archives from the sourceforge page at https://sourceforge.net/projects/fpdb/ and unpack it into a folder of your choice. + +Next create a directory called .fpdb (the . at the beginning is important) in your home directory, e.g. /home/steffen/.fpdb +Then copy the default.conf file from the docs directory of the archive into this new folder. +Finally edit default.conf with any texteditor and enter the fpdb password you entered above (in the GRANT ALL... command). + +This should be it, try double clicking pyfpdb/fpdb.py or open it from a shell with python /path/to/fpdb/pyfpdb/fpdb.py + +Now see readme-user.txt for usage instructions. + + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt new file mode 100644 index 00000000..a8a3f988 --- /dev/null +++ b/docs/known-bugs-and-planned-features.txt @@ -0,0 +1,58 @@ +Everything is subject to change and the order does not indicate priority. Patches for any of these or other features are very welcome, see readme-overview.txt for contacts. +Please also see db-todo.txt + +before beta +=========== +change to savannah? + + + +Any comment or print with "todo" in it in the sourcecode except what is marked todo in the menu +make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file +Make tab and enter work as sensible in GUIs and implement Ctrl+Q, Ctrl+X and Alt+F4 for close. +use profile file for bulk import and table viewer settings and pathes +check that we read sitout correctly in: Full Tilt Poker Game #6150325318: Table Bogside +verify at least 2 or 3 sng hands + +no rush but before 1.0RC +======================== +improve handling of dead hand before BB, see git101/7bd1631 +make DB version error offer reimport, recreation and continue. +In many places there are unnecessary database accesses or it regenerates information it already had before or just generally does things in obscenely inefficient ways. Optimise this +multi-select in bulk importer +cut down action_types array size to appropriate length +make the gui display errors +log file +move directory import code from gui to backend +convert fpdb_import to not require passing "self", generally clean the parameter passing +Doesn't handle Daylight Saving Time (I don't think at least) +ensure that refresh still takes no more than 10 seks on my P3M-800 (a quick run on git15 indicates this is ok now), or 5 with remote DB +select range of stakes and sng/mtt values and types for hud +recognise somewhere if a file is still active and if so keep it open and only read new hands rather than detecting dupes +return full ftp functionality + +can wait till 1.x +================= +in all importer: stop doing if site=="ftp", make class constants for site_id instead +It treats fold due to disconnect as voluntary fold which is not ideal +aliases +repair hands where the seat lines are missing, happens when observing at FTP +flags for storing the reason for winning (best hi, tie for best low, etc.) to DB. not sure actually if this is such a good idea remember that there can be multiple reasons for the same player in the same hand +benchmark properly on mysql innodb, postgresql, more? +rename things like this: ClassName.methodName and variableName. update codingstyle +CLI (not ncurses, normal CLI) equivalent for fpdb.py +optimise/simplify storing by creating the SQL statements depending on hand rather than calling different methods +make range of activeSeats configurable for tv/hud + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/readme-dev.txt b/docs/readme-dev.txt new file mode 100644 index 00000000..25e013bd --- /dev/null +++ b/docs/readme-dev.txt @@ -0,0 +1,67 @@ +Hi, +This document is to serve as a little overview (later: full technical doc) for current and prospective developers with: +a) introduction into the code structure +b) organisational/legal things + +What to do? +=========== +- Anything you want. +- The most useful (because it's the most boring) would be to update print_hand.py, update the expected files (testdata/*.found.txt) and create more .found.txt to ensure import processing is running correctly. +- There's a list of various bugs, deficiencies and important missing features in known_bugs_and_planned_features.txt. +- In the main GUI there's various menu points marked with todo - all of these will have to be done eventually. + +If you want to take a look at coding-style.txt. +Ideally use git (see git-instructions.txt for some commands) and let me know where to pull from, alternatively feel free to send patches or even just changed file in whatever code layout or naming convention you like best. I will, of course, still give you full credit. + +Contact/Communication +===================== +If you start working on something please open a bug or feature request at sf to avoid someone else from doing the same +Please see readme-overview + +Dependencies +============ +Please let me know before you add any new dependencies and ensure that they are source-compatible between *nix and Windows + +Code/File/Class Structure +========================= +Basically the code runs like this + +fpdb.py -> bulk importer tab (import_threaded.py) -> fpdb_import.py -> fpdb_parse_logic.py -> fpdb_save_to_db.py +or +fpdb.py -> table viewer tab (table_viewer.py) (todo: -> libTableViewer) + +All files call the simple methods that I just collected in fpdb_simple.py, to abstract the other files off the nitty gritty details as I was learning python. +I'm currently working on (amongst other things) integrating everything into the fpdb.py GUI with a view to allow easy creation of a CLI client, too. + +Also see filelist.txt. + +How to Commit +============= +Please make sure you read and accept the copyright policy as stated in this file. Then see git-instructions.txt. Don't get me wrong, I hate all this legalese, but unfortunately it's kinda necessary. + +Copyright/Licensing +=================== +Copyright by default is handled on a per-file basis. If you send in a patch or make a commit to an existing file it is done on the understanding that you transfer all rights (as far as legally possible in your jurisdiction) to the current copyright holder of that file, unless otherwise stated. If you create a new file please ensure to include a copyright and license statement. + +The licenses used by this project are the AGPL3 for code and FDL1.2 for documentation. See readme-overview.txt for reasons and if you wish to use fpdb with different licensing. + +Preferred File Formats +====================== +Preferred: Where possible simple text-based formats, e.g. plain text (with Unix end of line char) or (X)HTML. Preferred picture format is PNG. IE-compability for HTML files is optional as IE was never meant to be a real web browser, if it were they would've implemented web standards. + +Also good: Other free and open formats, e.g. ODF. + +Not good: Any format that doesn't have full documentation freely and publicly available with a proper license for anyone to implement it. Sadly, Microsoft has chosen not fulfil these requirements for ISO MS OOXML to become a truly open standard. + +License (of this file) +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/readme-overview.txt b/docs/readme-overview.txt new file mode 100644 index 00000000..825a61de --- /dev/null +++ b/docs/readme-overview.txt @@ -0,0 +1,86 @@ +Summary +======= +A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt + +Contact +======= +Please note that this project has two hostings: one at assembla.com which holds are version control "central tree" (irrelevant for users) and everything else at http://sourceforge.net/projects/fpdb/. + +The best means of contact are the sourceforge page: Use the bug, feature request or patch functions or just post in the forum. + +Alternatively feel free to contact me directly: + +mail: steffen(at)sycamoretest.info +jabber/xmpp/Google Talk: as above +ICQ: 7806355 +MSN: steffenjf@gmx.de (don't email that) + +But you could send all my hand histories to yourself! +===================================================== +At the end of the day this comes down to a question of trust, but unlike Windows and the poker client software you don't have to trust fpdb blindly. You can: +- Verify the source code yourself. +- Convince or pay someone to verify the source code for you. +- Use a personal firewall to completely block fpdb from the Internet +- (for the uber-paranoid) Get yourself the free virtualisation software VirtualBox, set up a VM (virtual machine) to run fpdb but run the poker software on your real PC. Then cut the VM off the Internet, fpdb doesn't need it. If you have a PC made in the last few years this should run fast enough as well. Note that most Windows licenses do NOT permit you to use two Windows installations at once, even if they are on the same PC. + +Installing +========== +See the install-*.txt for your operating system. If your OS is missing or if you have problems let me know (contacts are further below). In particular I'd be happy to provide packages for GNU/Linux and *BSD distributions. + +Using it +======== +See readme-user.txt +If you have a problem, request or question see the contacts section below + +Changing it +=========== +See readme-dev.txt + +Requirements +============ +Software requirements are listed in requirements.txt +As for hardware, my main test machine is a Pentium 3-M 800 with 256 RAM and Gentoo GNU/Linux +(running the poker client through what most people will call emulation). So this +program will have to work on that. If you run an even more ancient machine and +its too slow let me know and I'll see what I can do :) + +Why Free Software? +================== +This program is released under the terms of the free/libre software license AGPL3 as released by the FSF. The AGPL3 protects your rights and those of the wider community. As Richard Stallman, one of the founders of the free software movement, put it: "Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer." (well, it is both really, like the right to vote used to be free) + +For example, a "pirated" copy of proprietary software X is free of charge, but you don't actually have a legal right to use it, you don't have any possibility to fix its bugs and you certainly don't have any legal right to share it with your friends. You also won't be able to get support, often not even security fixes. Actually, even if you pay hundreds of pounds for your program they deny your right to fix their errors for them. Imagine buying a car where you're not permitted (under threat of jail) to replace broken parts.. + +With free/libre software (also known as open source software, or short FOSS or FLOSS) on the other hand you get all these freedoms: +(note: the legally binding terms are in the license text, this is merely an amateur summary so normal people don't have to read pages of legalese) + +Freedom 0: The freedom to use: To run the program, for any purpose. Free of Charge. +Freedom 1: The freedom to study and help yourself. This freedom guarantees your right to study and learn from the source code of the program, and to fix it if it is broken. If you're not a programmer yourself the developers will generally be happy to fix it for you, often even for free. Failing that you can always pay someone from the money you saved on not having to pay for it. +Freedom 2: The freedom to be a decent human being and help your neighbour: I don't threaten you with lawsuits or jail time if you share with your friends and neighbours, subject to the very modest restrictions of the AGPL3. +Freedom 3: The freedom to improve the program and release your improvements to the public (or parts thereof) so that the whole community benefits. Note that you are PERMITTED, but not REQUIRED to distribute your changes. If you do distribute your changes you must do so under the terms of the AGPL3 however. + +Note that this is the license - I retain full copyright over my code, including the right to change the license for future versions. I do not intend to do this however. In any case, any version I released under AGPL3 remains available under that license forever, or more accurately until my copyright expires at which point it goes into the public domain. + +I reject the concept of software patents as a crime and under the European Patent Agreement software patents - even if you mislabel them as "computer-implemented inventions" or whatever - are explicitly prohibited. + +Can I get/use this under a different license? +============================================= +The short answer: Maybe. +The long one: As detailed, I fully support what the FSF does and aims to achieve with the GPL. However, I realise that many free software developers don't object to closed source, some don't even object to closed source profiteering of their charity, and I don't think I have any right to go and tell them they're wrong. +So if anyone wishes to use all or part of my code in another free software/open source project with an AGPL3-incompatible license such as BSD then let me know and we'll figure out a solution that makes everyone happy. +If you wish to use all or part of this in closed source let me know how much if anything that is worth to you and I'm sure we'll be able to reach an agreement. Note that you are NOT permitted to just use fpdb code in closed source development whether in-house or by an independent software developer, you will NEED an additionally agreement with me to get fpdb under different licensing conditions. + + +License of this Document +======================== +The views expressed in this document are those of Steffen Jobbagy-Felso, other members of the fpdb team and external contributors may or may not agree. + +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/readme-user.txt b/docs/readme-user.txt new file mode 100644 index 00000000..6d3d1f76 --- /dev/null +++ b/docs/readme-user.txt @@ -0,0 +1,43 @@ +Before you do this make sure you setup the dependencies, the database, user, tables and config file. + +Running it +========== +If you have python setup properly you can execute it by double clicking pyfpdb/fpdb.py. + +Note however that all error messages are currently only printed if you call it from a shell. It'll be much easier to diagnose possible problems (which are likely in alpha stage) if you run it from a shell. In Windows XP it seems to automatically open a shell window with the fpdb window where you can see the command line output. + +In Linux/MacOS/*BSD, e.g. if its in /home/sycamore/fpdb/, do this: +cd /home/sycamore/fpdb/pyfpdb +python fpdb.py + + +That will start the main GUI. + +Have a look at the menus, the stuff that is marked todo is not yet implemented. + +The main things are the bulk importer and the table viewer. To use the importer open it from the menu (import files and directories). You can set a few options at the bottom, then select a folder or single file in the main are and click Import. Please report any errors by one of the contacts listed in readme-overview.txt. +Currently this will block the interface, but you can open another instance of this program e.g. if you wanna play whilst a big import is running. + +Please check the output at the shell for errors, if there are any please get in touch by one of the methods listed in readme-overview.txt + +Table Viewer (tv) +================= +To use the table viewer open it from the menu, select the hand history file of the table you're at, and click the Import&Read&Refresh button. The abbreviations there are explained in abbreviations.txt, but feel free to ask. Note that most poker software will only create the file once the first hand you payed to play is finished. +In each column there is either just the number (hand count for current stake, range of seats and type of game) or a percentage and the number of hands that this percentage is based on. For example, in W$@SD (won $ at shodown) the number in brackets is how many showdowns that player has seen. + +Reimporting +=========== +Currently on most updates a reimport of the whole database is required. To do this open fpdb, click the menu Database and select Create/Recreate tables. Then import all your history files again. + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/release-notes.txt b/docs/release-notes.txt new file mode 100644 index 00000000..c8ff9444 --- /dev/null +++ b/docs/release-notes.txt @@ -0,0 +1,93 @@ +alpha2 +====== +Hi everyone, +we are proud to announce the second alpha release of fpdb, the free/libre open source poker tracker. The biggest highlight is the HUD for Linux made by Ray (and perhaps Mac, not sure). But for everyone fpdb now also supports PS tournaments (SnG and MTT) and FTP ring games. There is also a new auto-importer though it currently only runs on one file per instance (but you can open multiple instances of fpdb). +Fpdb also parses alot of new situations into the cache table for the HUD, most of which are already available through the Linux HUD. There have also been a large number of bugfixes for all kinds of things. For full details of the changes see the git commit comments. + +You can download fpdb at https://sourceforge.net/project/showfiles.php?group_id=226872 + +Our website at http://fpdb.sourceforge.net/ will be updated shortly but in the meantime please note that the configuration file now resides in ~/.fpdb/default.conf on Linux/Mac and in C:\Documents and Settings\Application Data\fpdb\default.conf on Windows (on non-English Windows you have to translate the Documents and Settings, but not the Application data bit). Apart from that just follow the instructions on the site. I will be updating/improving the fpdb ebuild for Gentoo next week, please send me a PM or email if you would like a package for another Linux/BSD. + +To use the HUD in Linux simply run the auto importer whilst having the table open. You will also have to rename HUD_config.xml.example to HUD_config.xml and edit the database parameters in there in addition to what is written in the install guide. + +If you've been using fpdb alpha1 just delete the fpdb folder, follow the installation guide except for installing the dependencies, then run fpdb and run recreate tables. Note that you will have to reimport ALL your history files. + +For external devs (in particular Youre Toast): The table design has gone through some changes, though most of it was just renaming to make a consistent naming scheme and to make it more flexible towards stud/razz type games. I do not expect to having to make any future changes to the existing fields but I cannot yet guarantee that. There will be some additional fields in particular in the HudCache table. Please let me know if you need any further fields. I realise my naming breaks the "database designer's convention" but for this project I feel ignoring this convention for the benefit of consistent naming between Python and SQL is ok. + + +Any questions and comments please post here, send me a PM or email, post a feature request or bug report on sourceforge or use any of the other means of contact listed on our webpage. + +Enjoy, +The fpdb team + +PS: I personally will be away Sun-Tue so I probably won't be responding to anything but feel free to message me anyways, but if you post here or at SF someone else might be able to help. + +PPS: If you wanna know EXACTLY how this project is moving along follow the git tree over at [url]http://www.assembla.com/spaces/fpdb/trac_git_tool[/url] + + +alpha1 +====== +Hi everyone, +I am proud to announce the first release of my new poker tracking software fpdb (freepokerdb, very imaginative I know ;) ). You may wonder why I bothered when now with HM and PT3 there are at least two excellent packages to choose from. + +Four main reasons: +1. Fpdb is free/libre open source software. In short, this means you don't depend on me if sth. is wrong or you want something more in this program as you can freely change it yourself. You also don't have to pay anything for it. If you like it and think I deserve to be paid just drop me a mail ;) +2. HM and PT3 only support holdem. Fpdb initially supports Holdem and Omaha, with Stud and Razz mostly implemented and coming soon. +3. HM and PT3 run on Windows only, and for me at least did not work in wine even after installing Mono. Fpdb runs on any plattform that has the required software, which will cover roundabout 99.9% of PCs. Currently tested plattforms are Windows XP-x86 and Gentoo GNU/Linux-amd64 as well as -x86. + You still need to run Windows or wine to run the actual poker client though. +4. Fpdb won't irritate you with copy prevention measures. + +To install it go to https://sourceforge.net/project/showfiles.php?group_id=226872 and download the zip or tar.bz2, unpack it, and follow the instructions in docs/install-in-* for your operating system (e.g. docs\install-in-windows.txt). Sourceforge lists the release files as source files, not as binary executables - this is correct, python will automagically compile as and when required. + +This is alpha1, as the name indicates it is still at a very early stage. The importer and database are nearing completion but the GUI in particular is not very functional yet and the HUD is missing alltogether. + +If anyone wishes to help with development that would be very very welcome and I've put a few notes in docs/readme-dev.txt in the download for what you could do. Or just start coding and send me the patches :) +If you're not a programmer and you're not interested in learning it you can still help simply by trying it out and sending bug reports and feature requests. To avoid unrealistic expectations I'd like to state that it'll be a long time until fpdb reaches feature parity to established paid-for closed source software. + +Feature List (short now, growing fast ;) ): + +You can edit/add whatever you like, it's all python and SQL. The code should be fairly straightforward I think and I put some notes into readme-dev.txt but feel free to ask. + +Backend, Distribution +===================== +- Choice of MySQL/InnoDB or PostgreSQL. (not tested on PostgreSQL) +- It is possible to run the database on one PC, the importer on another, and then access the database with the table viewer or HUD from a third PC. (note: do NOT do this unencrypted over an untrusted network like your employer's LAN or the Internet!) + +Site/Game Support +================= +- Initially only full support for PS, FTP coming soon +- Supports Holdem, Omaha Hi and Omaha Hi/Lo. Stud and Razz coming soon. +- Supports No Limit, Pot Limit, Fixed Limit NL, Cap NL and Cap PL + Note that currently it does not display extra stats for NL/PL so usefulness is limited for these limit types. Suggestions welcome, I don't play these. +- Supports ring/cash games, SnG/MTT coming soon + +Tableviewer (tv) +=========== +Tv takes a history filename and loads the appropriate players' stats and displays them in a tabular format. These stats currently are: + - VPIP, PFR and Preflop 3B/4B (3B/4B is not quite correct I think) + - Raise and Fold % on flop, turn and river. Fold only counts hands when someone raised. This can be displayed per street or as one combined value each for aggression and folding. + - Number of hands this is based on. + - SD/F (aka WtSD, proportion of hands where player went to showdown after seeing flop) + - W$wSF (Won $ when seen Flop) + - W$@SD (Won $ at showdown) + For all stats it also displays how many hands this particular is based on + + +IMPORTANT: The database format WILL undergo more changes and at this point I am not planning to write a converter so please keep your history files so you can re-import when necessary. Independent of this you should always keep the original raw files in a safe place with any tracking software. Should you however end up loosing your files somehow let me know and I'll try to help. + +Please send any feedback, feature requests/suggestions, bug reports and animal names to steffen@sycamoretest.info, pick one of the contact methods listed in readme-overview.txt, send me a PM here or reply to this post. + + + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..3ab5fbf8 --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,76 @@ +For all support please note that the tables WILL be changed, almost certainly without keeping backwards compatibility. Therefore you should keep your history files after import so you can re-import when necessary. Should you lose history files and need a "database updater" let me know. + +If support for another site/game would encourage you to help with this software please let me know at steffen@sycamoretest.info. + +IMPORTANT: There appears to be a bug in at least up to git34 in reading WtSD/W$wsF/W$SD + +Holdem/Omaha ring games on PokerStars +====================================== +Works, quite well tested, works in table viewer and is useful now. Functionality is quite limited so far though. This includes the holdem/omaha parts of HORSE, HOSE and any other mixed game + +Stud/Razz ring games on PokerStars +================================== +Broken - used to work, hardly tested. Needs to be updated to new infrastructure using a HudData table rather than hands_players_flags. Will fix this shortly. + +Tournaments/SnGs +================ +Broken - used to work, hardly tested. Needs to be updated to new infrastructure.. Will probably fix this shortly + +Full Tilt Poker +=============== +Might work - used to work and was very well test. It should import them (except HudData), but I believe the table viewer won't work. Would be easy to fix I think, volunteers welcome. This used to work in a pre-alpha but basically was left behind during updates to the other stuff. + +Other Sites +=========== +Patches/Volunteers welcome. Should be quite easy. + +GUI +=== +Alpha - the infrastructure stands and is fast enough, now "just" need to add more functionality. + +HUD +=== +Not started - volunteers welcome. I found a *nix utility based on xlib that does half the work for this (most of the other half is already in the table viewer), see http://www.roard.com/docs/cookbook/cbsu19.html. There's also a python implementation of xlib which should run even on Windows. + +Packaging +========= +Gentoo GNU/Linux: I'll make ebuilds, if you want one now let me know. +Other free/libre systems (e.g. other GNU/Linux-Distros, *BSD, and I'd love to help in getting this to work on any Hurd based system): Let me know what you use (Distribution, version and CPU type) and I'll make a package. +Windows/MacOSX: Manual installation of dependencies for now, integrated installer would be nice - volunteers welcome, but I'll do it eventually in any case. + +Regression Testing +================== +The query scripts are done-ish, need to verify more data so it can be used in automated regression testing. + +Database Backends +================= +- MySQL InnoDB is the default +- PostgreSQL should work but I haven't tried it. If it doesn't please let me know. +- MySQL ISAM won't be supported since it is not transactional + +Legal +===== +General: This will offer more or less the same kind of functionality as HM and PT so there shouldn't be any problem on any site that allows tracking. +PS: I have asked them and they said that due to the fast changing nature + of pre-release software they don't review that. However, looking at their + posted guidelines we're fine +FTP: I sent them an email and what I described there was ok for them. +I will write them again for "certification" on release of 1.0 + +To avoid any misunderstandings, PS and FTP obviously do not sponsor, endorse, or support fpdb. They allow using it, that's all. Any problems with fpdb should be reported to us, not the poker site. + +A note on viewing/tracking mucked hands. Many people will say this is cheating. I agree. However, I don't make the rules on these sites. The sites that store mucked hands into the history file clearly think that being able to see other people's mucked hands is ok. This software - like HM and PT - merely takes info provided by the poker site and makes it more easily accessible. +Apparently PS has now turned this off :) + +License +======= +Trademarks of third parties have been used under Fair Use or similar laws. + +Copyright 2008 Steffen Jobbagy-Felso +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.2 as published by the Free Software Foundation; with +no Invariant Sections, no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license can be found in fdl-1.2.txt + +The program itself is licensed under AGPLv3, see agpl-3.0.txt diff --git a/docs/tabledesign.html b/docs/tabledesign.html new file mode 100644 index 00000000..ce39d4bc --- /dev/null +++ b/docs/tabledesign.html @@ -0,0 +1,920 @@ + + + + + Free Poker DB Tabledesign + + +

See commit comments for version info, see status.txt for status.

+

Direct suggestions, praise and animal names to steffen@sycamoretest.info or check readme-overview.txt for more contacts

+

I decided to be generous on the sizes of the types - if computing experience shows one thing then its that it will come back to bite you in the ass if you save 2 bits in the wrong place. If performance and/or db size are too bad we can still shrink some fields.

+

Relationships are noted in the comment (need to double check that all are listed)

+

If you want more comments or if anything is confusing or bad let me know.

+

All money/cash amounts are stored in cents/pennies/whatever (e.g. $4.27 would be stored a 427). Chips are stored as-is (e.g. 3675 chips would be stored as 3675).

+

Notes on use/editing:

+

Any change to this must be carried to to the table creation code in fpdb_db.py or at least an entry to known bugs is to be made.

+

If the code (in particular the importer) and this document disagree then this document is to be considered authorative.

+

License
+Trademarks of third parties have been used under Fair Use or similar laws.
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 as published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license can be found in fdl-1.2.txt
+The program itself is licensed under AGPLv3, see agpl-3.0.txt

+

See readme.txt for copying

+

Table Settings

+ + + + + + + + + + + +

Field name

Type

Comment

version

smallint

the git version of the database (ie. table design changes and major bugfixes require a bump)

+

Table Players

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

int


name

varchar(32)


siteId

smallint

references Sites.id

comment

text


commentTs

datetime (in UTC)


+


+

Table Autorates

+

An autorating is a computer-"recognised" label/category for a player. Examples could include "Calling Station" if a player has <20% each for aggression and folding postflop. Or "Tight-Aggressive/Aggressive" for players with <20% VPIP, >10% PFR and >40% postflop aggression.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

bigint


playerId

int

references Players.id

gametypeId

smallint

references Gametypes.id

description

varchar(50)

autorating description

shortDesc

char(8)

short description e.g. for display in HUD

ratingTime

datetime (in UTC)

timestamp of rating

handCount

int

number of hands rating is based on

+


+

Table Gametypes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

smallint


siteId

smallint

references sites.id

type

char(4)

valid entries:
+ ring - ringgames aka cash games
+ tour - tournament incl SnG

base

char(4)

The underlying structure. valid entries:
+ hold - Holdem and Omaha
+ stud - Stud and Razz
+ draw - (incl Badugi)

category

varchar(9)

valid entries:
+ holdem=Texas Hold'em
+ omahahi=Omaha High only
+ omahahilo=Omaha 8 or better
+ razz=Razz
+ studhi=7 Card Stud High only
+ studhilo=7 Card Stud 8 or better
+ fivedraw=Five Card Draw
+ 27_1draw=2-7 Single Draw
+ 27_3draw=2-7 Tripple Draw
+ badugi=Badugi

limitType

char(2)

nl=No Limit
+ cn=Cap No Limit
+ pl=Pot Limit
+ cp=Cap Pot Limit
+ fl=Fixed Limit

hiLo

char(1)

Whether the game is hi, lo or both. Valid Entries:
+ h - High only
+ l - Low only
+ s - Hi/Lo Split

smallBlind

int


bigBlind

int


smallBet

int


bigBet

int


+


+

Table Sites

+ + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

smallint


name

varchar(32)


currency

char(3)

currency code, e.g. USD, GBP, EUR

+


+

Table Hands

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


tableName

varchar(20)

The site's name for the current table

siteHandNo

bigint

the site's hand number

gametypeId

smallint

references gametypes.id

handStart

datetime (in UTC)

start date&time of the hand

importTime

datetime (in UTC)

date&time of import of this hand

seats

smallint

number of used seats (ie. that got dealt cards)

maxSeats

smallint

number of available seats

comment

text


commentTs

datetime (in UTC)


+


+

Table BoardCards

+

cardX -> can be 1 through 5

+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


handId

bigint

the site's hand number

cardXValue

smallint

2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x, kept=k (draw only)

cardXSuit

char(1)

h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x

+


+

Table HandsPlayers

+

cardX: can be 1 through 20, one for each card. In holdem only 1-2 of these are used, in omaha 1-4, in stud/razz 1-7, in single draw games 1-10 is used and in badugi 1-16 (4*4) is used.

+

For the draw games: the first 5 (badugi: 4) cards are the initial cards, the next 5 (badugi: 4) are after the first draw. If a player keeps some cards then those cards' spaces are filled with "k", short for "kept".
+Example 1: If a player gets 2-6 spades for his first five cards and decides to throw away the 4 and then gets a 7 of spades then the first 10 fields of cardXValue would be as follows: 2, 3, 4, 5, 6, k, k, 7, k, k
+Example 2: If a player gets 2, 3, 5, 8, J of spades for his first five cards and decides to throw away the 2 and the 3 and then gets a Q and K of spades then the first 10 fields of cardXValue would be as follows: 2, 3, 5, 8, J, Q, K, k, k, k
+Note that it will k in the space of which card was there previously, so in example 2 where the player kept the last 3 cards, the last 3 fields of the first draw (ie. card8-10Value) are replaced with k.

+

I did not separate this into an extra table because I felt the lost space is not sufficiently large. Also the benefit for searching is far less relevant.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

+

Comment

id

bigint


handId

bigint

references Hands.id

playerId

int

references Players.id

startCash

int


position

char(1)

BB=B, SB=S, Button=0, Cutoff=1, etc.
+ This is used in holdem/omaha only.

seatNo

smallint

The seat in which the person was sitting - necessary for HUD

ante

int

note: for cash this could be boolean, but in tourneys you may enter a hand with less than the full ante

cardXValue

smallint

2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x
+ see note above table

cardXSuit

char(1)

h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x

winnings

int

winnings in this hand (bets, antes, etc. are NOT deducted, but rake already is)

rake

int

rake for this player for this hand

comment

text


commentTs

datetime (in UTC)


tourneysPlayersId

bigint

references TourneysPlayers.id

+


+

Table HudCache

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


gametypeId

smallint

references gametypes.id

playerId

int

references players.id

activeSeats

smallint

range 2-10

position

char(1)

Position for which this row applies. In this table this can be B(BB), S(SB), D(Dealer/Button), C(Cutoff), M(Middle - the 3 before cutoff) or E (Early - the 3 before Middle)

tourneyTypeId

smallint

References TourneyTypes.id

HDs

int

number of hands this player played in this gametype with this number of seats

street0VPI

int

number of hands where player paid to see flop
+ Please note that this already includes street0Aggr!
+ To calculate limp just deduct street0Aggr from this number

street0Aggr

int

number of hands where player raised before flop

street0_3B4BChance

int

number of hands where player had chance to 3B or 4B

street0_3B4BDone

int

number of hands where player 3bet/4bet before flop

street1Seen

int

number of hands where player saw flop/street4

street2Seen

int

number of hands where player saw turn/street5

street3Seen

int

number of hands where player saw river/street6

street4Seen

int

number of hands where player saw street7

sawShowdown

int

number of hands where player saw showdown

street1Aggr

int

number of hands where player raised flop/street4

street2Aggr

int

number of hands where player raised turn/street5

street3Aggr

int

number of hands where player raised river/street6

street4Aggr

int

number of hands where player raised street7

otherRaisedStreet1

int

number of hands where someone else raised flop/street4

otherRaisedStreet2

int

number of hands where someone else raised turn/street5

otherRaisedStreet3

int

number of hands where someone else raised river/street6

otherRaisedStreet4

int

number of hands where someone else raised street7

foldToOtherRaisedStreet1

int

number of hands where someone else raised flop/street4 and the player folded

foldToOtherRaisedStreet2

int

number of hands where someone else raised Turn/street5 and the player folded

foldToOtherRaisedStreet3

int

number of hands where someone else raised River/street6 and the player folded

foldToOtherRaisedStreet4

int

number of hands where someone else raised street7 and the player folded

wonWhenSeenStreet1

float

How many hands the player won after seeing the flop/street4 - this can be a "partial win" if the pot is split.
+ To be completely clear, this stores a hand count, NOT a money amount.

wonAtSD

float

As wonWhenSeenStreet1, but for showdown.

stealAttemptChance

int

Player was in CO, BTN or SB and nobody has called yet

stealAttempted

int

Player took a chance per the above condition

foldBbToStealChance

int

Somebody tried to steal BB from player

foldedBbToSteal

int

Player folded BB to steal attempt

foldSbToStealChance

int

Somebody tried to steal SB from player

foldedSbToSteal

int

Player folded SB to steal attempt

street1CBChance

int

Player had chance to make continuation bet on flop/street4

street1CBDone

int

Player used chance to make continuation bet on flop/street4

street2CBChance

int

Player had chance to make continuation bet on turn/street5

street2CBDone

int

Player used chance to make continuation bet on turn/street5

street3CBChance

int

Player had chance to make continuation bet on river/street6

street3CBDone

int

Player used chance to make continuation bet on river/street6

street4CBChance

int

Player had chance to make continuation bet on street7

street4CBDone

int

Player used chance to make continuation bet on street7

foldToStreet1CBChance

int

Player had chance to fold to continuation bet on this street

foldToStreet1CBDone

int

Player used chance to fold to continuation bet on this street

foldToStreet2CBChance

int

Player had chance to fold to continuation bet on this street

foldToStreet2CBDone

int

Player used chance to fold to continuation bet on this street

foldToStreet3CBChance

int

Player had chance to fold to continuation bet on this street

foldToStreet3CBDone

int

Player used chance to fold to continuation bet on this street

foldToStreet4CBChance

int

Player had chance to fold to continuation bet on this street

foldToStreet4CBDone

int

Player used chance to fold to continuation bet on this street

totalProfit

int

how much money in cents the player made

street1CheckCallRaiseChance

int

How often player had the chance to do a check-raise or a call-raise on this street

street1CheckCallRaiseDone

int

How often player used the chance to do a check-raise or a call-raise on this street

street2CheckCallRaiseChance

int

How often player had the chance to do a check-raise or a call-raise on this street

street2CheckCallRaiseDone

int

How often player used the chance to do a check-raise or a call-raise on this street

street3CheckCallRaiseChance

int

How often player had the chance to do a check-raise or a call-raise on this street

street3CheckCallRaiseDone

int

How often player used the chance to do a check-raise or a call-raise on this street

street4CheckCallRaiseChance

int

How often player had the chance to do a check-raise or a call-raise on this street

street4CheckCallRaiseDone

int

How often player used the chance to do a check-raise or a call-raise on this street

+

+

Table HandsActions

+

Did separate this into an extra table because it makes SELECTing across different streets so much easier. Also the space saving will be very large.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


handPlayerId

bigint

references HandsPlayers.id

street

smallint

street number, 0-3 (preflop, flop, turn, river) for holdem/omaha or 0-4 for razz/stud

-1 for seen showdown

actionNo

smallint

action number, this is counted from zero for each street but across all players (e.g. in a heads up where the SB calls and the BB raises and the SB calls again would have numbers 0 and 1 for blinds, 2 and 4 for call and 3 for bet)
+ Note that the blinds are counted as an action, so if the SB stays in the hand it'll always be action #0

action

char(5)

Bet stands for bring in, complete, bet, double bet, raise and double raise, since they all - technically - do the same thing. Unbet is used for when an uncalled bet is returned, this will have a negative value for amount.

+

Other valid values: blind call check fold

allIn

boolean

Whether the player went all-in on this action

amount

int

amount put into the middle for this action

comment

text


commentTs

datetime (in UTC)


+


+

Tournament Tables

+


+

Table Tourneys

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

int


tourneyTypeId

smallint

References TourneyTypes.id

siteTourneyNo

bigint


entries

int

-1 if unknown

prizepool

int

Need this as separate field to support rebuy/addon

-1 if unknown

startTime

datetime (in UTC)

Empty if unknown

comment

text


commentTs

datetime (in UTC)


+


+

Table TourneyTypes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field name

Type

Comment

id

int


siteId

smallint

References Sites.id

buyin

int

Buy-in in cents. Without rebuy/add-on

fee

int


knockout

int


rebuyOrAddon

boolean

Whether rebuys or add-ons are possible

+


+

Table TourneysPlayers

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


tourneyId

int

References Tourneys.id

playerId

int

References Players.id

payinAmount

int

Buyin, fee, rebuys and add-ons

rank

int

Finishing rank

winnings

signed int

Winnings (not profit) by this player, -1 if unknown.

comment

text


commentTs

datetime (in UTC)


+ + diff --git a/ignore-me_perl6/LibFpdbImport.pm b/ignore-me_perl6/LibFpdbImport.pm new file mode 100644 index 00000000..ac7db336 --- /dev/null +++ b/ignore-me_perl6/LibFpdbImport.pm @@ -0,0 +1,178 @@ +#!/usr/bin/pugs + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +module LibFpdbImport; +use v6; +#use strict; +use LibFpdbShared; +#use LibFpdbImport2; + +class Player { + has Str $name; + has Int $start_cash; + has Card @.cards; + has Char $position; + + submethod BUILD (Str @strings) { + say "todo: implement Player.BUILD"; + }#end Player.BUILD + + our Player method find_players(@strings) { + #todo: i think this should be sub since its a class method not an instance method + say "todo: implement Player.find_players"; + } +}#end class Player + +class Line { + has Str $line; + has Bool $processed; + + our protected submethod BUILD() { + say "todo: implement Line.BUILD?" + }#end Line.BUILD + + our Line method recognise_and_parse(@strings) { + #todo: i think this should be sub since its a class method not an instance method + say "todo: implement Line.recognise_and_parse"; + }#end Line.recognise_and_parse +}#end class Line + +class ActionLine is Line { + has Player $player; + has Str $type; + has Int $amount; + has Bool $all_in; + has Int $action_no; +}#end class ActionLine + +class WinLine is Line { + has Player $player; + has Int $amount; +}#end class WinLine + +class RakeLine is Line { + has Int $amount; +}#end class RakeLine + +class CardLine is Line { + has Bool $board_line; + has Player $player; + has Card @cards; +}#end class CardLine + +#for useless lines +class CrapLine is Line { + has Str $type; +}#end class CrapLine + +class Hand { + has Line @.lines; + #has Str @strings; + has Site $site; + has Str $currency; + + has Str $type; + has Str $category; + has Str $limit_type;#todo: above ; missing causes error, but that doesnt list ; as a possibility + has Player @.players; + has Card @.board; + has Int $db_id; + + submethod BUILD(Str @strings) { + Util.debug("running Hand.BUILD"); + say "strings:",@strings; + #this contructor automatically parses the hand. call .store for storing + + @.players=Player.find_players(@strings); + @.lines=Line.recognise_and_parse(@strings); + + for @strings -> $line { + if class_of(line)==CardLine { + if line.board { + board=line.cards; + } else { + for player in players { + if line.player==player { + player.cards=line.cards; + } + } + } + } + } + }#end Hand.BUILD + + our Bool method is_holdem(){ + if category==("holdem"|"omahahi"|"omahahilo") { + return True; + } else { + return False; + } + }#end Hand.is_holdem + + our Bool method is_stud(){ + return not is_holdem(); + }#end Hand.is_stud + + our Bool method store($db) { + say "todo: Hand.store"; + }#end Hand.store +}#end class Hand + +class Importer { +#todo: be Thread? + submethod BUILD (Database $db, Str $filename) { + Util.debug("running Importer.BUILD"); + if (not ($db.is_connected())) { + Util.fatal("not connected to DB"); + } + + my IO $?filehandle=$filename; + #for =$filehandle -> $line {say $line} + my Str @lines =$filehandle; + + my Int $hand_start=0; + my Int $hand_end=0; + my Int $loopcount=0; + loop {#one loop of this per hand + $loopcount++; + say "loopcount", $loopcount; + my Int $current_line_index=$hand_end+1; #previous hand end is new hand start + for (my Int $i, $i<5, $i++) {#remove blank hands + if (@lines[$current_line_index].bytes) < 6 { + $current_line_index++; + } else { + $hand_start=$current_line_index; + break; + } + } + my Bool $continue=True; #todo: this is dumb, find out correct loop + while $continue {#loop through the lines to find end of hand + $current_line_index++; + if (@lines[$current_line_index].bytes) < 6 { + $hand_end=$current_line_index; + $continue=False; + } + }#end of find end of hand loop + my Str @handlines=@lines[$hand_start..$hand_end]; + my Hand $hand .= new(:lines(@handlines)); + $hand.store($db); + say "todo: record \$db_id"; + say "todo: terminate on EOF"; + } + }#end new Importer +}#end class Importer + diff --git a/ignore-me_perl6/LibFpdbShared.pm b/ignore-me_perl6/LibFpdbShared.pm new file mode 100644 index 00000000..abf2eb69 --- /dev/null +++ b/ignore-me_perl6/LibFpdbShared.pm @@ -0,0 +1,84 @@ +#!/usr/bin/pugs + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +module LibFpdbShared; +use v6; +#use strict; + +class Util { + method debug(Str $string) { + #todo: i think this should be sub since its a class method not an instance method + say "debug notice: ", $string; + }#end debug_msg + + sub warn(Str $string) { + say "todo: Util.warning"; + }#end warning + + sub fatal(Str $string, Database $db) { + say "todo: Util.fatal_error"; + }#end fatal_error +}#end class Util + +class Database { + has Str $backend; + has Str $host; + has Str $name; + has Str $user; + my Str $password; + submethod BUILD (Str $!backend, Str $!host, Str $!name, Str $!user, Str $!password) { + Util.debug("running Database.BUILD"); + self.connect(); + }#end new Database + + our method connect() { + say "todo: db.connect"; + }#end connect + + method disconnect() { + say "todo: db.disconnect"; + }#end disconnect + + method cancel_import() { + say "todo: db.cancel_import"; + }#end cancel_import + + my method drop_tables() { + #todo: make this one private + say "todo: db.drop_tables"; + }#end drop_tables + + method recreate_tables() { + say "todo: db.recreate_tables"; + }#end recreate_tables + + #returns the id of the insert + our Int method insert(Str $sql_command) { + #todo: is it a bug that i need the "our" above? + say "todo: db.insert"; + return 0; + }#end insert + + our Str method fetch(Str $sql_command) { + say "todo: db.fetch"; + }#end fetch + + our Bool method is_connected() { + say "todo: db.is_connected"; + }#end +}#end class Database + diff --git a/ignore-me_perl6/LibFpdbView.pm b/ignore-me_perl6/LibFpdbView.pm new file mode 100644 index 00000000..e4f994d1 --- /dev/null +++ b/ignore-me_perl6/LibFpdbView.pm @@ -0,0 +1,17 @@ +#!/usr/bin/pugs + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + diff --git a/ignore-me_perl6/RunFpdbCLI.perl6 b/ignore-me_perl6/RunFpdbCLI.perl6 new file mode 100644 index 00000000..90401cdf --- /dev/null +++ b/ignore-me_perl6/RunFpdbCLI.perl6 @@ -0,0 +1,29 @@ +#!/usr/bin/pugs + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +use v6; +#use strict; +use LibFpdbImport; +use LibFpdbShared; + + +my Database $db .= new(:backend, :host, :database, :user, :password); +#todo: below doesnt work +my Importer $imp .= new(:db($db), :filename); +#perlbug?: adding another named argument that isnt listed in the constructor gave very weird error. +say $imp; + diff --git a/packaging/gentoo/fpdb-1.0_alpha8_p137.ebuild b/packaging/gentoo/fpdb-1.0_alpha8_p137.ebuild new file mode 100644 index 00000000..c55903f3 --- /dev/null +++ b/packaging/gentoo/fpdb-1.0_alpha8_p137.ebuild @@ -0,0 +1,62 @@ +# Copyright 1999-2008 Gentoo Foundation +# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $ + +NEED_PYTHON=2.3 + +#inherit distutils + +MY_P="fpdb-${PV}" +DESCRIPTION="A database program to track your online poker games" +HOMEPAGE="https://sourceforge.net/projects/fpdb/" +SRC_URI="mirror://sourceforge/fpdb/${MY_P}.tar.bz2" + +LICENSE="AGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +#note: this should work on other architectures too, please send me your experiences +IUSE="" + +RDEPEND="virtual/mysql + dev-python/mysql-python + >=x11-libs/gtk+-2.10 + dev-python/pygtk + dev-python/numpy + dev-python/matplotlib" + +DEPEND="${RDEPEND}" + +src_install() { + DIRINST="${D}usr/share/games/fpdb/" + mkdir -p "${DIRINST}" + cp -R * "${DIRINST}" || die + + DIRBIN="${D}usr/games/bin/" + mkdir -p "${DIRBIN}" + #echo "pathes" + #echo "${DIRINST}pyfpdb/fpdb.py" + #echo "${DIRBIN}fpdb.py" + #echo + echo "cd /usr/share/games/fpdb/pyfpdb/ && python fpdb.py" > "${DIRBIN}fpdb" || die + chmod 755 "${DIRBIN}fpdb" || die +} + +#src_test() { +#} + +pkg_postinst() { + elog "Fpdb has been installed and can be called by executing /usr/games/bin/fpdb" + elog "You need to perform a couple more steps manually." + elog "Please also make sure you followed instructions from previous emerges, in particular make sure you configured mysql and set a root pw for it" + elog "Now run this command to connect to MySQL: mysql --user=root --password=yourPassword" + elog "In the mysql command line interface you need to type these two lines (make sure you get the ; at the end)" + elog "In the second line replace \"newPassword\" with a password of your choice" + elog "CREATE DATABASE fpdb;" + elog "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;" + elog "Finally copy the default config file from ${DIRINST}docs/default.conf to ~/.fpdb/ for every user that is to use fpdb." + elog "You will need to edit the default.conf, in particular you need to replace the password with what you entered in the \"GRANT ALL...\"" + elog "Finally run the GUI and click the menu database -> recreate tables" + elog "That's it! See our webpage at http://fpdb.sourceforge.net for more documentation" + elog " " +} diff --git a/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild b/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild new file mode 100644 index 00000000..c55903f3 --- /dev/null +++ b/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild @@ -0,0 +1,62 @@ +# Copyright 1999-2008 Gentoo Foundation +# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $ + +NEED_PYTHON=2.3 + +#inherit distutils + +MY_P="fpdb-${PV}" +DESCRIPTION="A database program to track your online poker games" +HOMEPAGE="https://sourceforge.net/projects/fpdb/" +SRC_URI="mirror://sourceforge/fpdb/${MY_P}.tar.bz2" + +LICENSE="AGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +#note: this should work on other architectures too, please send me your experiences +IUSE="" + +RDEPEND="virtual/mysql + dev-python/mysql-python + >=x11-libs/gtk+-2.10 + dev-python/pygtk + dev-python/numpy + dev-python/matplotlib" + +DEPEND="${RDEPEND}" + +src_install() { + DIRINST="${D}usr/share/games/fpdb/" + mkdir -p "${DIRINST}" + cp -R * "${DIRINST}" || die + + DIRBIN="${D}usr/games/bin/" + mkdir -p "${DIRBIN}" + #echo "pathes" + #echo "${DIRINST}pyfpdb/fpdb.py" + #echo "${DIRBIN}fpdb.py" + #echo + echo "cd /usr/share/games/fpdb/pyfpdb/ && python fpdb.py" > "${DIRBIN}fpdb" || die + chmod 755 "${DIRBIN}fpdb" || die +} + +#src_test() { +#} + +pkg_postinst() { + elog "Fpdb has been installed and can be called by executing /usr/games/bin/fpdb" + elog "You need to perform a couple more steps manually." + elog "Please also make sure you followed instructions from previous emerges, in particular make sure you configured mysql and set a root pw for it" + elog "Now run this command to connect to MySQL: mysql --user=root --password=yourPassword" + elog "In the mysql command line interface you need to type these two lines (make sure you get the ; at the end)" + elog "In the second line replace \"newPassword\" with a password of your choice" + elog "CREATE DATABASE fpdb;" + elog "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;" + elog "Finally copy the default config file from ${DIRINST}docs/default.conf to ~/.fpdb/ for every user that is to use fpdb." + elog "You will need to edit the default.conf, in particular you need to replace the password with what you entered in the \"GRANT ALL...\"" + elog "Finally run the GUI and click the menu database -> recreate tables" + elog "That's it! See our webpage at http://fpdb.sourceforge.net for more documentation" + elog " " +} diff --git a/packaging/windows/fpdbEnvInstaller2.au3 b/packaging/windows/fpdbEnvInstaller2.au3 new file mode 100644 index 00000000..73b7cb92 --- /dev/null +++ b/packaging/windows/fpdbEnvInstaller2.au3 @@ -0,0 +1,182 @@ +;"%programfiles%\MySQL\MySQL Server 5.0\bin\mysqld" --remove +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Includes +#include + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Variables +Dim $rootPwd = "" +Dim $fpdbUserPwd = "" + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Welcome message and option to abort. Change of working dir to \fpdbEnv +Dim $welcomeBox = MsgBox(4100, "fpdb environment installation", "This installer will automatically create the environment which is needed to run fpdb." & @CRLF & @CRLF & _ +"This means installing and configuring MySQL and Python including some special modules," & @CRLF & "creating a directory for your fpdb user profile and adding gtk to your path." & @CRLF & @CRLF & _ +"You are advised to close all aplications before you proceed." & @CRLF & @CRLF & _ +"DON'T use the keyboard or the mouse during installation unless you are asked to! Just WAIT until the message box 'End of Installation' pops up!" & @CRLF & @CRLF & _ +"If you want to continue the installation click 'Yes'." & @CRLF & "If you want to abort the installation click 'No'.") +If $welcomeBox == 7 Then + Exit ;Exit Installation if 'No' button is clicked in message box +EndIf + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Ask user for mysql root password +GUICreate("FPDB Environment Installation", 600, 400) +GUICtrlCreateLabel("For the installation of the FPDB Environment the MySQL root password and your poker database password are needed.", 20, 25) +GUICtrlCreateLabel("In case MySQL and/or your fpdb poker database aren't installed on your computer, just pick a password.", 20, 50) +GUICtrlCreateLabel("MySQL Root Password:", 20, 100) +$rootPw = GUICtrlCreateInput("your password here", 150, 100, 100, 20) +GUICtrlCreateLabel("Retype password:", 290, 100) +$rootPwR = GUICtrlCreateInput("", 420, 100, 100, 20) +GUICtrlCreateLabel("Poker DB User Password:", 20, 150) +$userPw = GUICtrlCreateInput("your password here", 150, 150, 100, 20) +GUICtrlCreateLabel("Retype password:", 290, 150) +$userPwR = GUICtrlCreateInput("", 420, 150, 100, 20) +$okbutton = GUICtrlCreateButton("OK", 270, 200, 60, 20) +$status = GUICtrlCreateLabel("This is the status line. It describes what the installer is doing at the moment.", 20, 250, 560) +GUISetState(@SW_SHOW) +While 1 + $msg = GUIGetMsg() + Select + Case $msg = $okbutton + If Not(GUICtrlRead($rootPw) == GUICtrlRead($rootPwR)) OR GUICtrlRead($rootPw) == "" Then + MsgBox(16, "", "The passwords don't macht! Try again!", 20, 250) + ElseIf Not(GUICtrlRead($userPw) == GUICtrlRead($userPwR)) OR GUICtrlRead($userPw) == "" Then + MsgBox(16, "", "The passwords don't macht! Try again!", 20, 250) + Else + $rootPwd = GUICtrlRead($rootPw) + $fpdbUserPwd = GUICtrlRead($userPw) + GUICtrlSetState($okbutton, $GUI_DISABLE) + ExitLoop + EndIf + EndSelect +WEnd + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Files Needed +FileInstall("fpdb\7za.exe", "7za.exe") +FileInstall("fpdb\MySQL Server 5.0.7z", "MySQL Server 5.0.7z") +FileInstall("fpdb\gtk.7z", "gtk.7z") +FileInstall("fpdb\python-2.5.2.msi", "python-2.5.2.msi") +FileInstall("fpdb\pymysql.7z", "pymysql.7z") +FileInstall("fpdb\pycairo.7z", "pycairo.7z") +FileInstall("fpdb\pygobject.7z", "pygobject.7z") +FileInstall("fpdb\pygtk.7z", "pygtk.7z") +FileInstall("fpdb\psykopg2.7z", "psykopg2.7z") +FileInstall("fpdb\pywin32.7z", "pywin32.7z") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; MySQL Install and configuration +If NOT FileExists(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql.exe") Then + GUICtrlSetData($status, "Installing MySQL Database Management System and creating MySQL windows service.") + RunWait('7za.exe x "MySQL Server 5.0.7z" -o"' & EnvGet("programfiles") & '\MySQL\" -aoa', "", @SW_HIDE) + RunWait('"' & EnvGet("programfiles") & '\MySQL\MySQL Server 5.0\bin\mysqld" --install', "", @SW_HIDE) + RunWait("net start mysql", "", @SW_HIDE) + ProcessWait("mysqld.exe") + GUICtrlSetData($status, "Securing important MySQL user accounts.") + Sleep(5000) + FileWrite(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql1.txt", "DELETE FROM mysql.user WHERE User = '';" & @CRLF) + FileWrite(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql1.txt", "UPDATE mysql.user SET Password = PASSWORD('" & $rootPwd & "') WHERE User = 'root';" & @CRLF) + FileWrite(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql1.txt", "FLUSH PRIVILEGES;" & @CRLF) + RunWait(@ComSpec & ' /c mysql --user=root -e "source mysql1.txt"', EnvGet("programfiles") & '\MySQL\MySQL Server 5.0\bin\', @SW_HIDE) +EndIf +If NOT FileExists(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\data\fpdb") Then + GUICtrlSetData($status, "Creating fpdb database.") + FileWrite(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql2.txt", "create database fpdb;" & @CRLF) + RunWait(@ComSpec & ' /c mysql --user=root --password=' & $rootPwd & ' -e "source mysql2.txt"', EnvGet("programfiles") & '\MySQL\MySQL Server 5.0\bin\', @SW_HIDE) +EndIf +GUICtrlSetData($status, "Creating MySQL user 'fpdb' and granting privileges.") +FileWrite(EnvGet("programfiles") & "\MySQL\MySQL Server 5.0\bin\mysql3.txt", "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY '" & $fpdbUserPwd & "' WITH GRANT OPTION;" & @CRLF) +RunWait(@ComSpec & ' /c mysql --user=root --password=' & $rootPwd & ' -e "source mysql3.txt"', EnvGet("programfiles") & '\MySQL\MySQL Server 5.0\bin\', @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; GTK +GUICtrlSetData($status, "Installing GTK.") +RunWait('7za.exe x "gtk.7z" -oc:\ -aoa', "", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Python 2.5 Installation +GUICtrlSetData($status, "Installing Python 2.5.2") +RunWait("msiexec /quiet /i python-2.5.2.msi", "", @SW_HIDE) ;Install Python without user interaction + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pymysql +GUICtrlSetData($status, "Installing pymysql") +RunWait('7za.exe x "pymysql.7z" -oC:\Python25\Lib\site-packages -aoa', "", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pycairo +GUICtrlSetData($status, "Installing pycairo") +RunWait('7za.exe x "pycairo.7z" -oC:\ -aoa', "", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pygobject +GUICtrlSetData($status, "Installing pygobject") +RunWait('7za.exe x "pygobject.7z" -oC:\ -aoa', "", @SW_HIDE) +RunWait(@ComSpec & ' /c C:\Python25\python.exe pygobject_postinstall.py -install', "C:\Python25\SCRIPTS", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pygtk +GUICtrlSetData($status, "Installing pygtk") +RunWait('7za.exe x "pygtk.7z" -oC:\ -aoa', "", @SW_HIDE) +RunWait(@ComSpec & ' /c C:\Python25\python.exe pygtk_postinstall.py -install', "C:\Python25\SCRIPTS", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; psykopg2 +GUICtrlSetData($status, "Installing psykopg2") +RunWait('7za.exe x "psykopg2.7z" -oC:\ -aoa', "", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; pywin32 +GUICtrlSetData($status, "Installing pywin32 for Python 2.5") +RunWait('7za.exe x "pywin32.7z" -oC:\ -aoa', "", @SW_HIDE) +RunWait(@ComSpec & ' /c C:\Python25\python.exe pywin32_postinstall.py -install', "C:\Python25\SCRIPTS", @SW_HIDE) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Creating directory for default.conf and coping the file into it +GUICtrlSetData($status, "Creating and installing default.conf file.") +$file = FileOpen("default.conf", 1) +FileWriteLine($file, "db-backend=2" & @CRLF) +FileWriteLine($file, "db-host=localhost" & @CRLF) +FileWriteLine($file, "db-databaseName=fpdb" & @CRLF) +FileWriteLine($file, "db-user=fpdb" & @CRLF) +FileWriteLine($file, "db-password=" & $fpdbUserPwd & @CRLF) +FileWriteLine($file, "tv-combinedStealFold=True" & @CRLF) +FileWriteLine($file, "tv-combined2B3B=True" & @CRLF) +FileWriteLine($file, "tv-combinedPostflop=True" & @CRLF) +FileWriteLine($file, "bulkImport-defaultPath=default" & @CRLF) +FileWriteLine($file, "hud-defaultPath=default" & @CRLF) +FileWriteLine($file, "imp-callFpdbHud=True" & @CRLF) +FileClose($file) +FileCopy("default.conf", EnvGet("appdata") & "\fpdb\", 9) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Registry +GUICtrlSetData($status, "Creating backup of path variable and adding GTK and Python to path variable.") +RegWrite("HKEY_CURRENT_USER\Environment", "PathBackup", "REG_SZ", RegRead("HKEY_CURRENT_USER\Environment", "path")) +RegWrite("HKEY_CURRENT_USER\Environment", "path", "REG_SZ", RegRead("HKEY_CURRENT_USER\Environment", "path") & ';C:\gtk\bin;C:\Python25') + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Delete installation files +GUICtrlSetData($status, "Deleting temporary installation files.") +FileDelete("7za.exe") +FileDelete("MySQL Server 5.0.7z") +FileDelete("gtk.7z") +FileDelete("python-2.5.2.msi") +FileDelete("pymysql.7z") +FileDelete("pycairo.7z") +FileDelete("pygobject.7z") +FileDelete("pygtk.7z") +FileDelete("psykopg2.7z") +FileDelete("pywin32.7z") +FileDelete("default.conf") + +$goodbyeBox = MsgBox(4100, "End of Installation", "The Computer needs to be restarted for the installation to be complete." & @CRLF & _ + "After that you can start fpdb by double clicking the file fpdb.py which is located in the folder pyfpdb of the fpdb build you downloaded." & @CRLF & _ + "If you haven't downloaded fpdb yet you can do it here: http://ovh.dl.sourceforge.net/sourceforge/fpdb/fpdb-alpha2-p68.zip" & @CRLF & @CRLF & _ + "If you want to restart the computer now click 'Yes'." & @CRLF & _ + "If you want to restart the computer later click 'No'.") +If $goodbyeBox == 7 Then + Exit ;Exit Installation if 'No' button is clicked in message box +EndIf +Run("shutdown.exe -r -t 0") \ No newline at end of file diff --git a/prepare-git.sh b/prepare-git.sh new file mode 100755 index 00000000..91b008e9 --- /dev/null +++ b/prepare-git.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +rm regression-test/*.found.txt +rm regression-test/*.pyc +rm pyfpdb/*.pyc + +git-add--interactive diff --git a/pyfpdb/Cards01.png b/pyfpdb/Cards01.png new file mode 100644 index 00000000..2c64fc9e Binary files /dev/null and b/pyfpdb/Cards01.png differ diff --git a/pyfpdb/CliFpdb.py b/pyfpdb/CliFpdb.py new file mode 100755 index 00000000..47649728 --- /dev/null +++ b/pyfpdb/CliFpdb.py @@ -0,0 +1,66 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import os +import sys +import fpdb_simple +from optparse import OptionParser + +try: + import MySQLdb +except: + diaSQLLibMissing = gtk.Dialog(title="Fatal Error - SQL interface library missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK)) + + print "Please note that the CLI importer only works with MySQL, if you use PostgreSQL this error is expected." + +import fpdb_import +import fpdb_db + +if __name__ == "__main__": + #process CLI parameters + parser = OptionParser() + parser.add_option("-c", "--handCount", default="0", type="int", + help="Number of hands to import (default 0 means unlimited)") + parser.add_option("-d", "--database", default="fpdb", help="The MySQL database to use (default fpdb)") + parser.add_option("-e", "--errorFile", default="failed.txt", + help="File to store failed hands into. (default: failed.txt) Not implemented.") + parser.add_option("-f", "--inputFile", "--file", "--inputfile", default="stdin", + help="The file you want to import (remember to use quotes if necessary)") + parser.add_option("-m", "--minPrint", "--status", default="50", type="int", + help="How often to print a one-line status report (0 means never, default is 50)") + parser.add_option("-p", "--password", help="The password for the MySQL user") + parser.add_option("-q", "--quiet", action="store_true", + help="If this is passed it doesn't print a total at the end nor the opening line. Note that this purposely does NOT change --minPrint") + parser.add_option("-s", "--server", default="localhost", + help="Hostname/IP of the MySQL server (default localhost)") + parser.add_option("-u", "--user", default="fpdb", help="The MySQL username (default fpdb)") + parser.add_option("-x", "--failOnError", action="store_true", + help="If this option is passed it quits when it encounters any error") + + (options, sys.argv) = parser.parse_args() + + settings={'imp-callFpdbHud':False, 'db-backend':2} + settings['db-host']=options.server + settings['db-user']=options.user + settings['db-password']=options.password + settings['db-databaseName']=options.database + settings['handCount']=options.handCount + settings['failOnError']=options.failOnError + + importer = fpdb_import.Importer(options, settings) + importer.addImportFile(options.inputFile) + importer.runImport() diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py new file mode 100755 index 00000000..5e599d4b --- /dev/null +++ b/pyfpdb/Configuration.py @@ -0,0 +1,578 @@ +#!/usr/bin/env python +"""Configuration.py + +Handles HUD configuration files. +""" +# Copyright 2008, Ray E. Barker + +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# Standard Library modules +import os +import sys +import string +import traceback +import shutil +import xml.dom.minidom +from xml.dom.minidom import Node + +class Layout: + def __init__(self, max): + self.max = int(max) + self.location = [] + for i in range(self.max + 1): self.location.append(None) + + def __str__(self): + temp = " Layout = %d max, width= %d, height = %d, fav_seat = %d\n" % (self.max, self.width, self.height, self.fav_seat) + temp = temp + " Locations = " + for i in range(1, len(self.location)): + temp = temp + "(%d,%d)" % self.location[i] + + return temp + "\n" + +class Site: + def __init__(self, node): + self.site_name = node.getAttribute("site_name") + self.table_finder = node.getAttribute("table_finder") + self.screen_name = node.getAttribute("screen_name") + self.site_path = node.getAttribute("site_path") + self.HH_path = node.getAttribute("HH_path") + self.decoder = node.getAttribute("decoder") + self.hudopacity = node.getAttribute("hudopacity") + self.hudbgcolor = node.getAttribute("bgcolor") + self.hudfgcolor = node.getAttribute("fgcolor") + self.converter = node.getAttribute("converter") + self.layout = {} + + for layout_node in node.getElementsByTagName('layout'): + max = int( layout_node.getAttribute('max') ) + lo = Layout(max) + lo.fav_seat = int( layout_node.getAttribute('fav_seat') ) + lo.width = int( layout_node.getAttribute('width') ) + lo.height = int( layout_node.getAttribute('height') ) + + for location_node in layout_node.getElementsByTagName('location'): + lo.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y'))) + + self.layout[lo.max] = lo + + def __str__(self): + temp = "Site = " + self.site_name + "\n" + for key in dir(self): + if key.startswith('__'): continue + if key == 'layout': continue + value = getattr(self, key) + if callable(value): continue + temp = temp + ' ' + key + " = " + str(value) + "\n" + + for layout in self.layout: + temp = temp + "%s" % self.layout[layout] + + return temp + +class Stat: + def __init__(self): + pass + + def __str__(self): + temp = " stat_name = %s, row = %d, col = %d, tip = %s, click = %s, popup = %s\n" % (self.stat_name, self.row, self.col, self.tip, self.click, self.popup) + return temp + +class Game: + def __init__(self, node): + self.game_name = node.getAttribute("game_name") + self.db = node.getAttribute("db") + self.rows = int( node.getAttribute("rows") ) + self.cols = int( node.getAttribute("cols") ) + + self.stats = {} + for stat_node in node.getElementsByTagName('stat'): + stat = Stat() + stat.stat_name = stat_node.getAttribute("stat_name") + stat.row = int( stat_node.getAttribute("row") ) + stat.col = int( stat_node.getAttribute("col") ) + stat.tip = stat_node.getAttribute("tip") + stat.click = stat_node.getAttribute("click") + stat.popup = stat_node.getAttribute("popup") + stat.hudprefix = stat_node.getAttribute("hudprefix") + stat.hudsuffix = stat_node.getAttribute("hudsuffix") + + self.stats[stat.stat_name] = stat + + def __str__(self): + temp = "Game = " + self.game_name + "\n" + temp = temp + " db = %s\n" % self.db + temp = temp + " rows = %d\n" % self.rows + temp = temp + " cols = %d\n" % self.cols + + for stat in self.stats.keys(): + temp = temp + "%s" % self.stats[stat] + + return temp + +class Database: + def __init__(self, node): + self.db_name = node.getAttribute("db_name") + self.db_server = node.getAttribute("db_server") + self.db_ip = node.getAttribute("db_ip") + self.db_user = node.getAttribute("db_user") + self.db_type = node.getAttribute("db_type") + self.db_pass = node.getAttribute("db_pass") + + def __str__(self): + temp = 'Database = ' + self.db_name + '\n' + for key in dir(self): + if key.startswith('__'): continue + value = getattr(self, key) + if callable(value): continue + temp = temp + ' ' + key + " = " + value + "\n" + return temp + +class Mucked: + def __init__(self, node): + self.name = node.getAttribute("mw_name") + self.cards = node.getAttribute("deck") + self.card_wd = node.getAttribute("card_wd") + self.card_ht = node.getAttribute("card_ht") + self.rows = node.getAttribute("rows") + self.cols = node.getAttribute("cols") + self.format = node.getAttribute("stud") + + def __str__(self): + temp = 'Mucked = ' + self.name + "\n" + for key in dir(self): + if key.startswith('__'): continue + value = getattr(self, key) + if callable(value): continue + temp = temp + ' ' + key + " = " + value + "\n" + return temp + +class Popup: + def __init__(self, node): + self.name = node.getAttribute("pu_name") + self.pu_stats = [] + for stat_node in node.getElementsByTagName('pu_stat'): + self.pu_stats.append(stat_node.getAttribute("pu_stat_name")) + + def __str__(self): + temp = "Popup = " + self.name + "\n" + for stat in self.pu_stats: + temp = temp + " " + stat + return temp + "\n" + +class Import: + def __init__(self, node): + self.interval = node.getAttribute("interval") + self.callFpdbHud = node.getAttribute("callFpdbHud") + + def __str__(self): + return " interval = %s\n callFpdbHud = %s\n" % (self.interval, self.callFpdbHud) + +class Tv: + def __init__(self, node): + self.combinedStealFold = node.getAttribute("combinedStealFold") + self.combined2B3B = node.getAttribute("combined2B3B") + self.combinedPostflop = node.getAttribute("combinedPostflop") + + def __str__(self): + return (" combinedStealFold = %s\n combined2B3B = %s\n combinedPostflop = %s\n" % + (self.combinedStealFold, self.combined2B3B, self.combinedPostflop) ) + +class Config: + def __init__(self, file = None): + +# "file" is a path to an xml file with the fpdb/HUD configuration +# we check the existence of "file" and try to recover if it doesn't exist + + self.default_config_path = self.get_default_config_path() + if not file == None: # configuration file path has been passed + if not os.path.exists(file): + print "Configuration file %s not found. Using defaults." % (file) + sys.stderr.write("Configuration file %s not found. Using defaults." % (file)) + file = None + + if file == None: # configuration file path not passed or invalid + file = self.find_config() #Look for a config file in the normal places + + if file == None: # no config file in the normal places + file = self.find_example_config() #Look for an example file to edit + if not file == None: + pass + + if file == None: # that didn't work either, just die + print "No HUD_config_xml found. Exiting" + sys.stderr.write("No HUD_config_xml found. Exiting") + sys.exit() + +# Parse even if there was no real config file found and we are using the example +# If using the example, we'll edit it later + try: + print "Reading configuration file %s\n" % (file) + doc = xml.dom.minidom.parse(file) + except: + print "Error parsing %s. See error log file." % (file) + traceback.print_exc(file=sys.stderr) + print "press enter to continue" + sys.stdin.readline() + sys.exit() + + self.doc = doc + self.file = file + self.supported_sites = {} + self.supported_games = {} + self.supported_databases = {} + self.mucked_windows = {} + self.popup_windows = {} + +# s_sites = doc.getElementsByTagName("supported_sites") + for site_node in doc.getElementsByTagName("site"): + site = Site(node = site_node) + self.supported_sites[site.site_name] = site + +# s_games = doc.getElementsByTagName("supported_games") + for game_node in doc.getElementsByTagName("game"): + game = Game(node = game_node) + self.supported_games[game.game_name] = game + +# s_dbs = doc.getElementsByTagName("supported_databases") + for db_node in doc.getElementsByTagName("database"): + db = Database(node = db_node) + self.supported_databases[db.db_name] = db + +# s_dbs = doc.getElementsByTagName("mucked_windows") + for mw_node in doc.getElementsByTagName("mw"): + mw = Mucked(node = mw_node) + self.mucked_windows[mw.name] = mw + +# s_dbs = doc.getElementsByTagName("popup_windows") + for pu_node in doc.getElementsByTagName("pu"): + pu = Popup(node = pu_node) + self.popup_windows[pu.name] = pu + + for imp_node in doc.getElementsByTagName("import"): + imp = Import(node = imp_node) + self.imp = imp + + for tv_node in doc.getElementsByTagName("tv"): + tv = Tv(node = tv_node) + self.tv = tv + + db = self.get_db_parameters('fpdb') + if db['db-password'] == 'YOUR MYSQL PASSWORD': + df_file = self.find_default_conf() + if df_file == None: # this is bad + pass + else: + df_parms = self.read_default_conf(df_file) + self.set_db_parameters(db_name = 'fpdb', db_ip = df_parms['db-host'], + db_user = df_parms['db-user'], + db_pass = df_parms['db-password']) + self.save(file=os.path.join(self.default_config_path, "HUD_config.xml")) + + + def find_config(self): + """Looks in cwd and in self.default_config_path for a config file.""" + if os.path.exists('HUD_config.xml'): # there is a HUD_config in the cwd + file = 'HUD_config.xml' # so we use it + else: # no HUD_config in the cwd, look where it should be in the first place + config_path = os.path.join(self.default_config_path, 'HUD_config.xml') + if os.path.exists(config_path): + file = config_path + else: + file = None + return file + + def get_default_config_path(self): + """Returns the path where the fpdb config file _should_ be stored.""" + if os.name == 'posix': + config_path = os.path.join(os.path.expanduser("~"), '.fpdb') + elif os.name == 'nt': + config_path = os.path.join(os.environ["APPDATA"], 'fpdb') + else: config_path = None + return config_path + + + def find_default_conf(self): + if os.name == 'posix': + config_path = os.path.join(os.path.expanduser("~"), '.fpdb', 'default.conf') + elif os.name == 'nt': + config_path = os.path.join(os.environ["APPDATA"], 'fpdb', 'default.conf') + else: config_path = False + + if config_path and os.path.exists(config_path): + file = config_path + else: + file = None + return file + + def read_default_conf(self, file): + parms = {} + fh = open(file, "r") + for line in fh: + line = string.strip(line) + (key, value) = line.split('=') + parms[key] = value + fh.close + return parms + + def find_example_config(self): + if os.path.exists('HUD_config.xml.example'): # there is a HUD_config in the cwd + file = 'HUD_config.xml.example' # so we use it + print "No HUD_config.xml found, using HUD_config.xml.example.\n", \ + "A HUD_config.xml will be written. You will probably have to edit it." + sys.stderr.write("No HUD_config.xml found, using HUD_config.xml.example.\n" + \ + "A HUD_config.xml will be written. You will probably have to edit it.") + else: + file = None + return file + + def get_site_node(self, site): + for site_node in self.doc.getElementsByTagName("site"): + if site_node.getAttribute("site_name") == site: + return site_node + + def get_db_node(self, db_name): + for db_node in self.doc.getElementsByTagName("database"): + if db_node.getAttribute("db_name") == db_name: + return db_node + return None + + def get_layout_node(self, site_node, layout): + for layout_node in site_node.getElementsByTagName("layout"): + if layout_node.getAttribute("max") == None: + return None + if int( layout_node.getAttribute("max") ) == int( layout ): + return layout_node + + def get_location_node(self, layout_node, seat): + for location_node in layout_node.getElementsByTagName("location"): + if int( location_node.getAttribute("seat") ) == int( seat ): + return location_node + + def save(self, file = None): + if not file == None: + f = open(file, 'w') + self.doc.writexml(f) + f.close() + else: + shutil.move(self.file, self.file+".backup") + f = open(self.file, 'w') + self.doc.writexml(f) + f.close + + def edit_layout(self, site_name, max, width = None, height = None, + fav_seat = None, locations = None): + print "max = ", max + site_node = self.get_site_node(site_name) + layout_node = self.get_layout_node(site_node, max) + if layout_node == None: return + for i in range(1, max + 1): + location_node = self.get_location_node(layout_node, i) + location_node.setAttribute("x", str( locations[i-1][0] )) + location_node.setAttribute("y", str( locations[i-1][1] )) + self.supported_sites[site_name].layout[max].location[i] = ( locations[i-1][0], locations[i-1][1] ) + + def get_db_parameters(self, name = None): + if name == None: name = 'fpdb' + db = {} + try: + db['db-databaseName'] = name + db['db-host'] = self.supported_databases[name].db_ip + db['db-user'] = self.supported_databases[name].db_user + db['db-password'] = self.supported_databases[name].db_pass + db['db-server'] = self.supported_databases[name].db_server + if string.lower(self.supported_databases[name].db_server) == 'mysql': + db['db-backend'] = 2 + elif string.lower(self.supported_databases[name].db_server) == 'postgresql': + db['db-backend'] = 3 + else: db['db-backend'] = None # this is big trouble + except: + pass + return db + + def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None, + db_pass = None, db_server = None, db_type = None): + db_node = self.get_db_node(db_name) + if not db_node == None: + if not db_ip == None: db_node.setAttribute("db_ip", db_ip) + if not db_user == None: db_node.setAttribute("db_user", db_user) + if not db_pass == None: db_node.setAttribute("db_pass", db_pass) + if not db_server == None: db_node.setAttribute("db_server", db_server) + if not db_type == None: db_node.setAttribute("db_type", db_type) + if self.supported_databases.has_key(db_name): + if not db_ip == None: self.supported_databases[db_name].dp_ip = db_ip + if not db_user == None: self.supported_databases[db_name].dp_user = db_user + if not db_pass == None: self.supported_databases[db_name].dp_pass = db_pass + if not db_server == None: self.supported_databases[db_name].dp_server = db_server + if not db_type == None: self.supported_databases[db_name].dp_type = db_type + return + + def get_tv_parameters(self): + tv = {} + try: + tv['combinedStealFold'] = self.tv.combinedStealFold + tv['combined2B3B'] = self.tv.combined2B3B + tv['combinedPostflop'] = self.tv.combinedPostflop + except: # Default tv parameters + tv['combinedStealFold'] = True + tv['combined2B3B'] = True + tv['combinedPostflop'] = True + return tv + + def get_import_parameters(self): + imp = {} + try: + imp['imp-callFpdbHud'] = self.imp.callFpdbHud + imp['hud-defaultInterval'] = int(self.imp.interval) + except: # Default import parameters + imp['imp-callFpdbHud'] = True + imp['hud-defaultInterval'] = 10 + return imp + + def get_default_paths(self, site = "PokerStars"): + paths = {} + try: + paths['hud-defaultPath'] = os.path.expanduser(self.supported_sites[site].HH_path) + paths['bulkImport-defaultPath'] = os.path.expanduser(self.supported_sites[site].HH_path) + except: + paths['hud-defaultPath'] = "default" + paths['bulkImport-defaultPath'] = "default" + return paths + + def get_default_colors(self, site = "PokerStars"): + colors = {} + if self.supported_sites[site].hudopacity == "": + colors['hudopacity'] = 0.90 + else: + colors['hudopacity'] = float(self.supported_sites[site].hudopacity) + if self.supported_sites[site].hudbgcolor == "": + colors['hudbgcolor'] = "#FFFFFF" + else: + colors['hudbgcolor'] = self.supported_sites[site].hudbgcolor + if self.supported_sites[site].hudfgcolor == "": + colors['hudfgcolor'] = "#000000" + else: + colors['hudfgcolor'] = self.supported_sites[site].hudfgcolor + return colors + + def get_locations(self, site = "PokerStars", max = "8"): + + try: + locations = self.supported_sites[site].layout[max].location + except: + locations = ( ( 0, 0), (684, 61), (689, 239), (692, 346), + (586, 393), (421, 440), (267, 440), ( 0, 361), + ( 0, 280), (121, 280), ( 46, 30) ) + return locations + + def get_site_parameters(self, site): + """Returns a dict of the site parameters for the specified site""" + if not self.supported_sites.has_key(site): + return None + parms = {} + parms["converter"] = self.supported_sites[site].converter + parms["decoder"] = self.supported_sites[site].decoder + parms["hudbgcolor"] = self.supported_sites[site].hudbgcolor + parms["hudfgcolor"] = self.supported_sites[site].hudfgcolor + parms["hudopacity"] = self.supported_sites[site].hudopacity + parms["screen_name"] = self.supported_sites[site].screen_name + parms["site_path"] = self.supported_sites[site].site_path + parms["table_finder"] = self.supported_sites[site].table_finder + parms["HH_path"] = self.supported_sites[site].HH_path + return parms + + def set_site_parameters(self, site_name, converter = None, decoder = None, + hudbgcolor = None, hudfgcolor = None, + hudopacity = None, screen_name = None, + site_path = None, table_finder = None, + HH_path = None): + """Sets the specified site parameters for the specified site.""" + site_node = self.get_site_node(site_name) + if not db_node == None: + if not converter == None: site_node.setAttribute("converter", converter) + if not decoder == None: site_node.setAttribute("decoder", decoder) + if not hudbgcolor == None: site_node.setAttribute("hudbgcolor", hudbgcolor) + if not hudfgcolor == None: site_node.setAttribute("hudfgcolor", hudfgcolor) + if not hudopacity == None: site_node.setAttribute("hudopacity", hudopacity) + if not screen_name == None: site_node.setAttribute("screen_name", screen_name) + if not site_path == None: site_node.setAttribute("site_path", site_path) + if not table_finder == None: site_node.setAttribute("table_finder", table_finder) + if not HH_path == None: site_node.setAttribute("HH_path", HH_path) + + if self.supported_databases.has_key(db_name): + if not converter == None: self.supported_sites[site].converter = converter + if not decoder == None: self.supported_sites[site].decoder = decoder + if not hudbgcolor == None: self.supported_sites[site].hudbgcolor = hudbgcolor + if not hudfgcolor == None: self.supported_sites[site].hudfgcolor = hudfgcolor + if not hudopacity == None: self.supported_sites[site].hudopacity = hudopacity + if not screen_name == None: self.supported_sites[site].screen_name = screen_name + if not site_path == None: self.supported_sites[site].site_path = site_path + if not table_finder == None: self.supported_sites[site].table_finder = table_finder + if not HH_path == None: self.supported_sites[site].HH_path = HH_path + return + +if __name__== "__main__": + c = Config() + + print "\n----------- SUPPORTED SITES -----------" + for s in c.supported_sites.keys(): + print c.supported_sites[s] + print "----------- END SUPPORTED SITES -----------" + + + print "\n----------- SUPPORTED GAMES -----------" + for game in c.supported_games.keys(): + print c.supported_games[game] + print "----------- END SUPPORTED GAMES -----------" + + + print "\n----------- SUPPORTED DATABASES -----------" + for db in c.supported_databases.keys(): + print c.supported_databases[db] + print "----------- END SUPPORTED DATABASES -----------" + + print "\n----------- MUCKED WINDOW FORMATS -----------" + for w in c.mucked_windows.keys(): + print c.mucked_windows[w] + print "----------- END MUCKED WINDOW FORMATS -----------" + + print "\n----------- POPUP WINDOW FORMATS -----------" + for w in c.popup_windows.keys(): + print c.popup_windows[w] + print "----------- END MUCKED WINDOW FORMATS -----------" + + print "\n----------- IMPORT -----------" +# print c.imp + print "----------- END IMPORT -----------" + + print "\n----------- TABLE VIEW -----------" +# print c.tv + print "----------- END TABLE VIEW -----------" + + c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) + c.save(file="testout.xml") + + print "db = ", c.get_db_parameters() +# print "tv = ", c.get_tv_parameters() +# print "imp = ", c.get_import_parameters() + print "paths = ", c.get_default_paths("PokerStars") + print "colors = ", c.get_default_colors("PokerStars") + print "locs = ", c.get_locations("PokerStars", 8) + for site in c.supported_sites.keys(): + print "site = ", site, + print c.get_site_parameters(site) \ No newline at end of file diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py new file mode 100644 index 00000000..4039b256 --- /dev/null +++ b/pyfpdb/Database.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python +"""Database.py + +Create and manage the database objects. +""" +# Copyright 2008, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# postmaster -D /var/lib/pgsql/data + +# Standard Library modules +import sys +import traceback + +# pyGTK modules + +# FreePokerTools modules +import Configuration +import SQL + +class Database: + def __init__(self, c, db_name, game): + if c.supported_databases[db_name].db_server == 'postgresql': + # psycopg2 database module for posgres via DB-API + import psycopg2 + + try: + self.connection = psycopg2.connect(host = c.supported_databases[db_name].db_ip, + user = c.supported_databases[db_name].db_user, + password = c.supported_databases[db_name].db_pass, + database = c.supported_databases[db_name].db_name) + except: + print "Error opening database connection %s. See error log file." % (file) + traceback.print_exc(file=sys.stderr) + print "press enter to continue" + sys.stdin.readline() + sys.exit() + + elif c.supported_databases[db_name].db_server == 'mysql': + # mysql bindings + import MySQLdb + try: + self.connection = MySQLdb.connect(host = c.supported_databases[db_name].db_ip, + user = c.supported_databases[db_name].db_user, + passwd = c.supported_databases[db_name].db_pass, + db = c.supported_databases[db_name].db_name) + cur_iso = self.connection.cursor() + cur_iso.execute('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED') + cur_iso.close() + + except: + print "Error opening database connection %s. See error log file." % (file) + traceback.print_exc(file=sys.stderr) + print "press enter to continue" + sys.stdin.readline() + sys.exit() + + else: + print "Database = %s not recognized." % (c.supported_databases[db_name].db_server) + sys.stderr.write("Database not recognized, exiting.\n") + print "press enter to continue" + sys.exit() + + self.type = c.supported_databases[db_name].db_type + self.sql = SQL.Sql(game = game, type = self.type) + + def close_connection(self): + self.connection.close() + + def get_table_name(self, hand_id): + c = self.connection.cursor() + c.execute(self.sql.query['get_table_name'], (hand_id, )) + row = c.fetchone() + return row + + def get_last_hand(self): + c = self.connection.cursor() + c.execute(self.sql.query['get_last_hand']) + row = c.fetchone() + return row[0] + + def get_xml(self, hand_id): + c = self.connection.cursor() + c.execute(self.sql.query['get_xml'], (hand_id)) + row = c.fetchone() + return row[0] + + def get_recent_hands(self, last_hand): + c = self.connection.cursor() + c.execute(self.sql.query['get_recent_hands'], {'last_hand': last_hand}) + return c.fetchall() + + def get_hand_info(self, new_hand_id): + c = self.connection.cursor() + c.execute(self.sql.query['get_hand_info'], new_hand_id) + return c.fetchall() + + def get_actual_seat(self, hand_id, name): + c = self.connection.cursor() + c.execute(self.sql.query['get_actual_seat'], (hand_id, name)) + row = c.fetchone() + return row[0] + +# def get_cards(self, hand): +# this version is for the PTrackSv2 db +# c = self.connection.cursor() +# c.execute(self.sql.query['get_cards'], hand) +# colnames = [desc[0] for desc in c.description] +# cards = {} +# for row in c.fetchall(): +# s_dict = {} +# for name, val in zip(colnames, row): +# s_dict[name] = val +# cards[s_dict['seat_number']] = s_dict +# return (cards) + + def get_cards(self, hand): +# this version is for the fpdb db + c = self.connection.cursor() + c.execute(self.sql.query['get_cards'], hand) + colnames = [desc[0] for desc in c.description] + cards = {} + for row in c.fetchall(): + s_dict = {} + for name, val in zip(colnames, row): + s_dict[name] = val + cards[s_dict['seat_number']] = s_dict + return (cards) + + def get_stats_from_hand(self, hand, player_id = False): + c = self.connection.cursor() + + if not player_id: player_id = "%" +# get the players in the hand and their seats +# c.execute(self.sql.query['get_players_from_hand'], (hand, player_id)) + c.execute(self.sql.query['get_players_from_hand'], (hand, )) + names = {} + seats = {} + for row in c.fetchall(): + names[row[0]] = row[2] + seats[row[0]] = row[1] + +# now get the stats +# c.execute(self.sql.query['get_stats_from_hand'], (hand, hand, player_id)) + c.execute(self.sql.query['get_stats_from_hand'], (hand, hand)) + colnames = [desc[0] for desc in c.description] + stat_dict = {} + for row in c.fetchall(): + t_dict = {} + for name, val in zip(colnames, row): + t_dict[name] = val +# print t_dict + t_dict['screen_name'] = names[t_dict['player_id']] + t_dict['seat'] = seats[t_dict['player_id']] + stat_dict[t_dict['player_id']] = t_dict + return stat_dict + + def get_player_id(self, config, site, player_name): + print "site = %s, player name = %s" % (site, player_name) + c = self.connection.cursor() + c.execute(self.sql.query['get_player_id'], {'player': player_name, 'site': site}) + row = c.fetchone() + return row[0] + +if __name__=="__main__": + c = Configuration.Config() + + db_connection = Database(c, 'fpdb', 'holdem') # mysql fpdb holdem +# db_connection = Database(c, 'fpdb-p', 'test') # mysql fpdb holdem +# db_connection = Database(c, 'PTrackSv2', 'razz') # mysql razz +# db_connection = Database(c, 'ptracks', 'razz') # postgres + print "database connection object = ", db_connection.connection + print "database type = ", db_connection.type + + h = db_connection.get_last_hand() + print "last hand = ", h + + hero = db_connection.get_player_id(c, 'PokerStars', 'nutOmatic') + print "nutOmatic is id_player = %d" % hero + + stat_dict = db_connection.get_stats_from_hand(h) + for p in stat_dict.keys(): + print p, " ", stat_dict[p] + + print "nutOmatics stats:" + stat_dict = db_connection.get_stats_from_hand(h, hero) + for p in stat_dict.keys(): + print p, " ", stat_dict[p] + + db_connection.close_connection + + print "press enter to continue" + sys.stdin.readline() diff --git a/pyfpdb/FpdbSQLQueries.py b/pyfpdb/FpdbSQLQueries.py new file mode 100644 index 00000000..e582c681 --- /dev/null +++ b/pyfpdb/FpdbSQLQueries.py @@ -0,0 +1,645 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + + +############################################################################ +# +# File for DB queries used in fpdb +# + +import sys +import os + +class FpdbSQLQueries: + + def __init__(self, db): + self.query = {} + self.dbname = db + +#Boilerplate code. +# if(self.dbname == 'MySQL InnoDB'): +# self.query[''] = """ """ +# elif(self.dbname == 'PostgreSQL'): +# elif(self.dbname == 'SQLite'): + + + ################################ + # List tables + ################################ + if(self.dbname == 'MySQL InnoDB'): + self.query['list_tables'] = """SHOW TABLES""" + elif(self.dbname == 'PostgreSQL'): + self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'""" + elif(self.dbname == 'SQLite'): + self.query['list_tables'] = """ """ + + ################################################################## + # Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax + ################################################################## + + if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'): + self.query['drop_table'] = """DROP TABLE IF EXISTS """ + + + ################################ + # Create Tables + ################################ + + ################################ + # Create Settings + ################################ + if(self.dbname == 'MySQL InnoDB'): + self.query['createSettingsTable'] = """CREATE TABLE Settings ( + version SMALLINT NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT)""" + + elif(self.dbname == 'SQLite'): + #Probably doesn't work. + self.query['createSettingsTable'] = """ """ + + + ################################ + # Create Sites + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createSitesTable'] = """CREATE TABLE Sites ( + id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + name varchar(32) NOT NULL, + currency char(3) NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createSitesTable'] = """CREATE TABLE Sites ( + id SERIAL UNIQUE, PRIMARY KEY (id), + name varchar(32), + currency char(3))""" + elif(self.dbname == 'SQLite'): + self.query['createSitesTable'] = """ """ + + + ################################ + # Create Gametypes + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createGametypesTable'] = """CREATE TABLE Gametypes ( + id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), + type char(4) NOT NULL, + base char(4) NOT NULL, + category varchar(9) NOT NULL, + limitType char(2) NOT NULL, + hiLo char(1) NOT NULL, + smallBlind int, + bigBlind int, + smallBet int NOT NULL, + bigBet int NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createGametypesTable'] = """CREATE TABLE Gametypes ( + id SERIAL UNIQUE, PRIMARY KEY (id), + siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id), + type char(4), + base char(4), + category varchar(9), + limitType char(2), + hiLo char(1), + smallBlind int, + bigBlind int, + smallBet int, + bigBet int)""" + elif(self.dbname == 'SQLite'): + self.query['createGametypesTable'] = """ """ + + + ################################ + # Create Players + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createPlayersTable'] = """CREATE TABLE Players ( + id INT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + name VARCHAR(32) CHARACTER SET utf8 NOT NULL, + siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), + comment text, + commentTs DATETIME) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createPlayersTable'] = """CREATE TABLE Players ( + id SERIAL UNIQUE, PRIMARY KEY (id), + name VARCHAR(32), + siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id), + comment text, + commentTs timestamp without time zone)""" + elif(self.dbname == 'SQLite'): + self.query['createPlayersTable'] = """ """ + + + ################################ + # Create Autorates + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createAutoratesTable'] = """CREATE TABLE Autorates ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), + gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + description varchar(50) NOT NULL, + shortDesc char(8) NOT NULL, + ratingTime DATETIME NOT NULL, + handCount int NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createAutoratesTable'] = """CREATE TABLE Autorates ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), + gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + description varchar(50), + shortDesc char(8), + ratingTime timestamp without time zone, + handCount int)""" + elif(self.dbname == 'SQLite'): + self.query['createAutoratesTable'] = """ """ + + + ################################ + # Create Hands + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createHandsTable'] = """CREATE TABLE Hands ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + tableName VARCHAR(20) NOT NULL, + siteHandNo BIGINT NOT NULL, + gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + handStart DATETIME NOT NULL, + importTime DATETIME NOT NULL, + seats SMALLINT NOT NULL, + maxSeats SMALLINT NOT NULL, + comment TEXT, + commentTs DATETIME) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createHandsTable'] = """CREATE TABLE Hands ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + tableName VARCHAR(20), + siteHandNo BIGINT, + gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + handStart timestamp without time zone, + importTime timestamp without time zone, + seats SMALLINT, + maxSeats SMALLINT, + comment TEXT, + commentTs timestamp without time zone)""" + elif(self.dbname == 'SQLite'): + self.query['createHandsTable'] = """ """ + + + ################################ + # Create Gametypes + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createBoardCardsTable'] = """CREATE TABLE BoardCards ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), + card1Value smallint NOT NULL, + card1Suit char(1) NOT NULL, + card2Value smallint NOT NULL, + card2Suit char(1) NOT NULL, + card3Value smallint NOT NULL, + card3Suit char(1) NOT NULL, + card4Value smallint NOT NULL, + card4Suit char(1) NOT NULL, + card5Value smallint NOT NULL, + card5Suit char(1) NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createBoardCardsTable'] = """CREATE TABLE BoardCards ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + handId BIGINT, FOREIGN KEY (handId) REFERENCES Hands(id), + card1Value smallint, + card1Suit char(1), + card2Value smallint, + card2Suit char(1), + card3Value smallint, + card3Suit char(1), + card4Value smallint, + card4Suit char(1), + card5Value smallint, + card5Suit char(1))""" + elif(self.dbname == 'SQLite'): + self.query['createBoardCardsTable'] = """ """ + + + ################################ + # Create TourneyTypes + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes ( + id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), + buyin INT NOT NULL, + fee INT NOT NULL, + knockout INT NOT NULL, + rebuyOrAddon BOOLEAN NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes ( + id SERIAL, PRIMARY KEY (id), + siteId INT, FOREIGN KEY (siteId) REFERENCES Sites(id), + buyin INT, + fee INT, + knockout INT, + rebuyOrAddon BOOLEAN)""" + elif(self.dbname == 'SQLite'): + self.query['createTourneyTypesTable'] = """ """ + + + ################################ + # Create Tourneys + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createTourneysTable'] = """CREATE TABLE Tourneys ( + id INT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + siteTourneyNo BIGINT NOT NULL, + entries INT NOT NULL, + prizepool INT NOT NULL, + startTime DATETIME NOT NULL, + comment TEXT, + commentTs DATETIME) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createTourneysTable'] = """CREATE TABLE Tourneys ( + id SERIAL UNIQUE, PRIMARY KEY (id), + tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + siteTourneyNo BIGINT, + entries INT, + prizepool INT, + startTime timestamp without time zone, + comment TEXT, + commentTs timestamp without time zone)""" + elif(self.dbname == 'SQLite'): + self.query['createTourneysTable'] = """ """ + + ################################ + # Create HandsPlayers + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), + playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), + startCash INT NOT NULL, + position CHAR(1), + seatNo SMALLINT NOT NULL, + ante INT, + + card1Value smallint NOT NULL, + card1Suit char(1) NOT NULL, + card2Value smallint NOT NULL, + card2Suit char(1) NOT NULL, + card3Value smallint, + card3Suit char(1), + card4Value smallint, + card4Suit char(1), + card5Value smallint, + card5Suit char(1), + card6Value smallint, + card6Suit char(1), + card7Value smallint, + card7Suit char(1), + + winnings int NOT NULL, + rake int NOT NULL, + comment text, + commentTs DATETIME, + + tourneysPlayersId BIGINT UNSIGNED, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id)) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + handId BIGINT, FOREIGN KEY (handId) REFERENCES Hands(id), + playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), + startCash INT, + position CHAR(1), + seatNo SMALLINT, + ante INT, + + card1Value smallint, + card1Suit char(1), + card2Value smallint, + card2Suit char(1), + card3Value smallint, + card3Suit char(1), + card4Value smallint, + card4Suit char(1), + card5Value smallint, + card5Suit char(1), + card6Value smallint, + card6Suit char(1), + card7Value smallint, + card7Suit char(1), + + winnings int, + rake int, + comment text, + commentTs timestamp without time zone, + tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))""" + elif(self.dbname == 'SQLite'): + self.query['createHandsPlayersTable'] = """ """ + + + ################################ + # Create TourneysPlayers + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), + playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), + payinAmount INT NOT NULL, + rank INT NOT NULL, + winnings INT NOT NULL, + comment TEXT, + commentTs DATETIME) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), + playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), + payinAmount INT, + rank INT, + winnings INT, + comment TEXT, + commentTs timestamp without time zone)""" + elif(self.dbname == 'SQLite'): + self.query['createTourneysPlayersTable'] = """ """ + + + ################################ + # Create HandsActions + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + handPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handPlayerId) REFERENCES HandsPlayers(id), + street SMALLINT NOT NULL, + actionNo SMALLINT NOT NULL, + action CHAR(5) NOT NULL, + allIn BOOLEAN NOT NULL, + amount INT NOT NULL, + comment TEXT, + commentTs DATETIME) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + handPlayerId BIGINT, FOREIGN KEY (handPlayerId) REFERENCES HandsPlayers(id), + street SMALLINT, + actionNo SMALLINT, + action CHAR(5), + allIn BOOLEAN, + amount INT, + comment TEXT, + commentTs timestamp without time zone)""" + elif(self.dbname == 'SQLite'): + self.query['createHandsActionsTable'] = """ """ + + + ################################ + # Create HudCache + ################################ + + if(self.dbname == 'MySQL InnoDB'): + self.query['createHudCacheTable'] = """CREATE TABLE HudCache ( + id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), + gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), + activeSeats SMALLINT NOT NULL, + position CHAR(1), + tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + + HDs INT NOT NULL, + street0VPI INT NOT NULL, + street0Aggr INT NOT NULL, + street0_3B4BChance INT NOT NULL, + street0_3B4BDone INT NOT NULL, + + street1Seen INT NOT NULL, + street2Seen INT NOT NULL, + street3Seen INT NOT NULL, + street4Seen INT NOT NULL, + sawShowdown INT NOT NULL, + + street1Aggr INT NOT NULL, + street2Aggr INT NOT NULL, + street3Aggr INT NOT NULL, + street4Aggr INT NOT NULL, + + otherRaisedStreet1 INT NOT NULL, + otherRaisedStreet2 INT NOT NULL, + otherRaisedStreet3 INT NOT NULL, + otherRaisedStreet4 INT NOT NULL, + foldToOtherRaisedStreet1 INT NOT NULL, + foldToOtherRaisedStreet2 INT NOT NULL, + foldToOtherRaisedStreet3 INT NOT NULL, + foldToOtherRaisedStreet4 INT NOT NULL, + wonWhenSeenStreet1 FLOAT NOT NULL, + wonAtSD FLOAT NOT NULL, + + stealAttemptChance INT NOT NULL, + stealAttempted INT NOT NULL, + foldBbToStealChance INT NOT NULL, + foldedBbToSteal INT NOT NULL, + foldSbToStealChance INT NOT NULL, + foldedSbToSteal INT NOT NULL, + + street1CBChance INT NOT NULL, + street1CBDone INT NOT NULL, + street2CBChance INT NOT NULL, + street2CBDone INT NOT NULL, + street3CBChance INT NOT NULL, + street3CBDone INT NOT NULL, + street4CBChance INT NOT NULL, + street4CBDone INT NOT NULL, + + foldToStreet1CBChance INT NOT NULL, + foldToStreet1CBDone INT NOT NULL, + foldToStreet2CBChance INT NOT NULL, + foldToStreet2CBDone INT NOT NULL, + foldToStreet3CBChance INT NOT NULL, + foldToStreet3CBDone INT NOT NULL, + foldToStreet4CBChance INT NOT NULL, + foldToStreet4CBDone INT NOT NULL, + + totalProfit INT NOT NULL, + + street1CheckCallRaiseChance INT NOT NULL, + street1CheckCallRaiseDone INT NOT NULL, + street2CheckCallRaiseChance INT NOT NULL, + street2CheckCallRaiseDone INT NOT NULL, + street3CheckCallRaiseChance INT NOT NULL, + street3CheckCallRaiseDone INT NOT NULL, + street4CheckCallRaiseChance INT NOT NULL, + street4CheckCallRaiseDone INT NOT NULL) + ENGINE=INNODB""" + elif(self.dbname == 'PostgreSQL'): + self.query['createHudCacheTable'] = """CREATE TABLE HudCache ( + id BIGSERIAL UNIQUE, PRIMARY KEY (id), + gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), + playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), + activeSeats SMALLINT, + position CHAR(1), + tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + + HDs INT, + street0VPI INT, + street0Aggr INT, + street0_3B4BChance INT, + street0_3B4BDone INT, + street1Seen INT, + street2Seen INT, + street3Seen INT, + street4Seen INT, + sawShowdown INT, + street1Aggr INT, + street2Aggr INT, + street3Aggr INT, + street4Aggr INT, + otherRaisedStreet1 INT, + otherRaisedStreet2 INT, + otherRaisedStreet3 INT, + otherRaisedStreet4 INT, + foldToOtherRaisedStreet1 INT, + foldToOtherRaisedStreet2 INT, + foldToOtherRaisedStreet3 INT, + foldToOtherRaisedStreet4 INT, + wonWhenSeenStreet1 FLOAT, + wonAtSD FLOAT, + + stealAttemptChance INT, + stealAttempted INT, + foldBbToStealChance INT, + foldedBbToSteal INT, + foldSbToStealChance INT, + foldedSbToSteal INT, + + street1CBChance INT, + street1CBDone INT, + street2CBChance INT, + street2CBDone INT, + street3CBChance INT, + street3CBDone INT, + street4CBChance INT, + street4CBDone INT, + + foldToStreet1CBChance INT, + foldToStreet1CBDone INT, + foldToStreet2CBChance INT, + foldToStreet2CBDone INT, + foldToStreet3CBChance INT, + foldToStreet3CBDone INT, + foldToStreet4CBChance INT, + foldToStreet4CBDone INT, + + totalProfit INT, + + street1CheckCallRaiseChance INT, + street1CheckCallRaiseDone INT, + street2CheckCallRaiseChance INT, + street2CheckCallRaiseDone INT, + street3CheckCallRaiseChance INT, + street3CheckCallRaiseDone INT, + street4CheckCallRaiseChance INT, + street4CheckCallRaiseDone INT)""" + elif(self.dbname == 'SQLite'): + self.query['createHudCacheTable'] = """ """ + + ################################ + # Queries used in GuiGraphViewer + ################################ + + + # Returns all cash game handIds and the money won(winnings is the final pot) + # by the playerId for a single site. + if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): + self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers + INNER JOIN Players ON HandsPlayers.playerId = Players.id + INNER JOIN Hands ON Hands.id = HandsPlayers.handId + WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) + ORDER BY handStart""" + elif(self.dbname == 'SQLite'): + #Probably doesn't work. + self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers + INNER JOIN Players ON HandsPlayers.playerId = Players.id + INNER JOIN Hands ON Hands.id = HandsPlayers.handId + WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) + ORDER BY handStart""" + + # Returns the profit for a given ring game handId, Total pot - money invested by playerId + if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): + self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions + INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id + INNER JOIN Players ON HandsPlayers.playerId = Players.id + WHERE Players.name = %s AND HandsPlayers.handId = %s + AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" + elif(self.dbname == 'SQLite'): + #Probably doesn't work. + self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions + INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id + INNER JOIN Players ON HandsPlayers.playerId = Players.id + WHERE Players.name = %s AND HandsPlayers.handId = %s + AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" + + +if __name__== "__main__": + from optparse import OptionParser + + print "FpdbSQLQueries starting from CLI" + + #process CLI parameters + usage = "usage: %prog [options]" + parser = OptionParser() + parser.add_option("-t", "--type", dest="dbtype", help="Available 'MySQL InnoDB', 'PostgreSQL', 'SQLite'(default: MySQL InnoDB)", default="MySQL InnoDB") + parser.add_option("-s", "--show", action="store_true", dest="showsql", help="Show full SQL output") + parser.add_option("-v", "--verbose", action="store_true", dest="verbose") + + + (options, args) = parser.parse_args() + + if options.verbose: + print """No additional output available in this file""" + + obj = FpdbSQLQueries(options.dbtype) + + print "Available Queries for '" + options.dbtype + "':" + + for key in obj.query: + print " " + key + if options.showsql: + print obj.query[key] diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py new file mode 100644 index 00000000..916170f0 --- /dev/null +++ b/pyfpdb/GuiAutoImport.py @@ -0,0 +1,216 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import threading +import subprocess + +import pygtk +pygtk.require('2.0') +import gtk +import gobject +import os +import time +import fpdb_import + +class GuiAutoImport (threading.Thread): + def starsBrowseClicked(self, widget, data): + """runs when user clicks browse on auto import tab""" + #print "start of GuiAutoImport.starsBrowseClicked" + current_path=self.starsDirPath.get_text() + + dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import", + action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, + buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + #dia_chooser.set_current_folder(pathname) + dia_chooser.set_filename(current_path) + #dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import + + response = dia_chooser.run() + if response == gtk.RESPONSE_OK: + #print dia_chooser.get_filename(), 'selected' + self.starsDirPath.set_text(dia_chooser.get_filename()) + elif response == gtk.RESPONSE_CANCEL: + print 'Closed, no files selected' + dia_chooser.destroy() + #end def GuiAutoImport.starsBrowseClicked + + def tiltBrowseClicked(self, widget, data): + """runs when user clicks browse on auto import tab""" + #print "start of GuiAutoImport.tiltBrowseClicked" + current_path=self.tiltDirPath.get_text() + + dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import", + action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, + buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + #dia_chooser.set_current_folder(pathname) + dia_chooser.set_filename(current_path) + #dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import + + response = dia_chooser.run() + if response == gtk.RESPONSE_OK: + #print dia_chooser.get_filename(), 'selected' + self.tiltDirPath.set_text(dia_chooser.get_filename()) + elif response == gtk.RESPONSE_CANCEL: + print 'Closed, no files selected' + dia_chooser.destroy() + #end def GuiAutoImport.tiltBrowseClicked + + def do_import(self): + """Callback for timer to do an import iteration.""" + self.importer.runUpdated() + print "GuiAutoImport.import_dir done" + return True + + def startClicked(self, widget, data): + """runs when user clicks start on auto import tab""" + +# Check to see if we have an open file handle to the HUD and open one if we do not. +# bufsize = 1 means unbuffered +# We need to close this file handle sometime. + +# TODO: Allow for importing from multiple dirs - REB 29AUG2008 +# As presently written this function does nothing if there is already a pipe open. +# That is not correct. It should open another dir for importing while piping the +# results to the same pipe. This means that self.path should be a a list of dirs +# to watch. + try: #uhhh, I don't this this is the best way to check for the existence of an attr + getattr(self, "pipe_to_hud") + except AttributeError: + if os.name == 'nt': + command = "python HUD_main.py" + " %s" % (self.database) + bs = 0 # windows is not happy with line buffing here + self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, + universal_newlines=True) + else: + cwd = os.getcwd() + command = os.path.join(cwd, 'HUD_main.py') + bs = 1 + self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, + universal_newlines=True) +# self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, +# universal_newlines=True) +# command = command + " %s" % (self.database) +# print "command = ", command +# self.pipe_to_hud = os.popen(command, 'w') + self.starspath=self.starsDirPath.get_text() + self.tiltpath=self.tiltDirPath.get_text() + +# Add directory to importer object. + self.importer.addImportDirectory(self.starspath, True, "PokerStars", "passthrough") + self.importer.addImportDirectory(self.tiltpath, True, "FullTilt", "passthrough") + self.do_import() + + interval=int(self.intervalEntry.get_text()) + gobject.timeout_add(interval*1000, self.do_import) + #end def GuiAutoImport.startClicked + + def get_vbox(self): + """returns the vbox of this thread""" + return self.mainVBox + #end def get_vbox + + def __init__(self, settings, config, debug=True): + """Constructor for GuiAutoImport""" + self.settings=settings + self.config=config + self.importer = fpdb_import.Importer(self,self.settings) + self.importer.setCallHud(True) + self.importer.setMinPrint(30) + self.importer.setQuiet(False) + self.importer.setFailOnError(False) + self.importer.setHandCount(0) +# self.importer.setWatchTime() + + self.server=settings['db-host'] + self.user=settings['db-user'] + self.password=settings['db-password'] + self.database=settings['db-databaseName'] + + self.mainVBox=gtk.VBox(False,1) + self.mainVBox.show() + + self.settingsHBox = gtk.HBox(False, 0) + self.mainVBox.pack_start(self.settingsHBox, False, True, 0) + self.settingsHBox.show() + + self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:") + self.settingsHBox.pack_start(self.intervalLabel) + self.intervalLabel.show() + + self.intervalEntry=gtk.Entry() + self.intervalEntry.set_text(str(self.settings['hud-defaultInterval'])) + self.settingsHBox.pack_start(self.intervalEntry) + self.intervalEntry.show() + + self.pathHBox = gtk.HBox(False, 0) + self.mainVBox.pack_start(self.pathHBox, False, True, 0) + self.pathHBox.show() + + self.pathStarsLabel = gtk.Label("Path to PokerStars auto-import:") + self.pathHBox.pack_start(self.pathStarsLabel, False, False, 0) + self.pathStarsLabel.show() + + self.starsDirPath=gtk.Entry() + paths = self.config.get_default_paths("PokerStars") + self.starsDirPath.set_text(paths['hud-defaultPath']) + self.pathHBox.pack_start(self.starsDirPath, False, True, 0) + self.starsDirPath.show() + + self.browseButton=gtk.Button("Browse...") + self.browseButton.connect("clicked", self.starsBrowseClicked, "Browse clicked") + self.pathHBox.pack_start(self.browseButton, False, False, 0) + self.browseButton.show() + + self.pathTiltLabel = gtk.Label("Path to Full Tilt auto-import:") + self.pathHBox.pack_start(self.pathTiltLabel, False, False, 0) + self.pathTiltLabel.show() + + self.tiltDirPath=gtk.Entry() + paths = self.config.get_default_paths("Full Tilt") + self.tiltDirPath.set_text(paths['hud-defaultPath']) + self.pathHBox.pack_start(self.tiltDirPath, False, True, 0) + self.tiltDirPath.show() + + self.browseButton=gtk.Button("Browse...") + self.browseButton.connect("clicked", self.tiltBrowseClicked, "Browse clicked") + self.pathHBox.pack_start(self.browseButton, False, False, 0) + self.browseButton.show() + + self.startButton=gtk.Button("Start Autoimport") + self.startButton.connect("clicked", self.startClicked, "start clicked") + self.mainVBox.add(self.startButton) + self.startButton.show() + #end of GuiAutoImport.__init__ +if __name__== "__main__": + def destroy(*args): # call back for terminating the main eventloop + gtk.main_quit() + + settings = {} + settings['db-host'] = "192.168.1.100" + settings['db-user'] = "mythtv" + settings['db-password'] = "mythtv" + settings['db-databaseName'] = "fpdb" + settings['hud-defaultInterval'] = 10 + settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic' + settings['imp-callFpdbHud'] = True + + i = GuiAutoImport(settings) + main_window = gtk.Window() + main_window.connect("destroy", destroy) + main_window.add(i.mainVBox) + main_window.show() + gtk.main() diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py new file mode 100644 index 00000000..ee5af2c6 --- /dev/null +++ b/pyfpdb/GuiBulkImport.py @@ -0,0 +1,152 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import threading +import fpdb_simple +import fpdb_import +import pygtk +pygtk.require('2.0') +import gtk +import os #todo: remove this once import_dir is in fpdb_import + +class GuiBulkImport (threading.Thread): + def import_dir(self): + """imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it""" + self.path=self.inputFile + self.importer.addImportDirectory(self.path) + self.importer.runImport() + print "GuiBulkImport.import_dir done" + + def load_clicked(self, widget, data=None): + self.inputFile=self.chooser.get_filename() + + self.handCount=self.hand_count_tbuffer.get_text(self.hand_count_tbuffer.get_start_iter(), self.hand_count_tbuffer.get_end_iter()) + if (self.handCount=="unlimited" or self.handCount=="Unlimited"): + self.importer.setHandCount(0) + else: + self.importer.setHandCount(int(self.handCount)) + + self.errorFile="failed.txt" + + self.minPrint=self.min_print_tbuffer.get_text(self.min_print_tbuffer.get_start_iter(), self.min_print_tbuffer.get_end_iter()) + if (self.minPrint=="never" or self.minPrint=="Never"): + self.importer.setMinPrint(0) + else: + self.importer.setMinPrint=int(self.minPrint) + + self.quiet=self.info_tbuffer.get_text(self.info_tbuffer.get_start_iter(), self.info_tbuffer.get_end_iter()) + if (self.quiet=="yes"): + self.importer.setQuiet(False) + else: + self.importer.setQuiet(True) + + self.failOnError=self.fail_error_tbuffer.get_text(self.fail_error_tbuffer.get_start_iter(), self.fail_error_tbuffer.get_end_iter()) + if (self.failOnError=="no"): + self.importer.setFailOnError(False) + else: + self.importer.setFailOnError(True) + + if os.path.isdir(self.inputFile): + self.import_dir() + else: + self.importer.addImportFile(self.inputFile) + self.importer.runImport() + self.importer.clearFileList() + + def get_vbox(self): + """returns the vbox of this thread""" + return self.vbox + #end def get_vbox + + def run (self): + print "todo: implement bulk import thread" + #end def run + + def __init__(self, db, settings, config): + self.db=db + self.settings=settings + self.config=config + self.importer = fpdb_import.Importer(self,self.settings) + + self.vbox=gtk.VBox(False,1) + self.vbox.show() + + self.chooser = gtk.FileChooserWidget() + self.chooser.set_filename(self.settings['bulkImport-defaultPath']) + #chooser.set_default_response(gtk.RESPONSE_OK) + #self.filesel.ok_button.connect_object("clicked", gtk.Widget.destroy, self.filesel) + self.vbox.add(self.chooser) + self.chooser.show() + + + self.settings_hbox = gtk.HBox(False, 0) + self.vbox.pack_end(self.settings_hbox, False, True, 0) + self.settings_hbox.show() + + self.hand_count_label = gtk.Label("Hands to import per file") + self.settings_hbox.add(self.hand_count_label) + self.hand_count_label.show() + + self.hand_count_tbuffer=gtk.TextBuffer() + self.hand_count_tbuffer.set_text("unlimited") + self.hand_count_tview=gtk.TextView(self.hand_count_tbuffer) + self.settings_hbox.add(self.hand_count_tview) + self.hand_count_tview.show() + + self.min_hands_label = gtk.Label("Status every") + self.settings_hbox.add(self.min_hands_label) + self.min_hands_label.show() + + self.min_print_tbuffer=gtk.TextBuffer() + self.min_print_tbuffer.set_text("never") + self.min_print_tview=gtk.TextView(self.min_print_tbuffer) + self.settings_hbox.add(self.min_print_tview) + self.min_print_tview.show() + + + self.toggles_hbox = gtk.HBox(False, 0) + self.vbox.pack_end(self.toggles_hbox, False, True, 0) + self.toggles_hbox.show() + + self.info_label = gtk.Label("Print start/end info:") + self.toggles_hbox.add(self.info_label) + self.info_label.show() + + self.info_tbuffer=gtk.TextBuffer() + self.info_tbuffer.set_text("yes") + self.info_tview=gtk.TextView(self.info_tbuffer) + self.toggles_hbox.add(self.info_tview) + self.info_tview.show() + + self.fail_error_label = gtk.Label("Fail on error:") + self.toggles_hbox.add(self.fail_error_label) + self.fail_error_label.show() + + self.fail_error_tbuffer=gtk.TextBuffer() + self.fail_error_tbuffer.set_text("no") + self.fail_error_tview=gtk.TextView(self.fail_error_tbuffer) + self.toggles_hbox.add(self.fail_error_tview) + self.fail_error_tview.show() + + self.load_button = gtk.Button("Import") #todo: rename variables to import too + self.load_button.connect("clicked", self.load_clicked, "Import clicked") + self.toggles_hbox.add(self.load_button) + self.load_button.show() + + threading.Thread.__init__ ( self ) + print "initialised new bulk import thread (not actually a thread yet)" +#end class import_threaded diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py new file mode 100644 index 00000000..7385e9fe --- /dev/null +++ b/pyfpdb/GuiGraphViewer.py @@ -0,0 +1,145 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import threading +import pygtk +pygtk.require('2.0') +import gtk +import os +#import pokereval + +try: + from matplotlib.figure import Figure + from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas + from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar + from numpy import arange, cumsum + from pylab import * +except: + print "Failed to load libs for graphing, graphing will not function. Please install numpy and matplotlib if you want to use graphs." + print "This is of no consequence for other parts of the program, e.g. import and HUD are NOT affected by this problem." + +import fpdb_import +import fpdb_db + +class GuiGraphViewer (threading.Thread): + def get_vbox(self): + """returns the vbox of this thread""" + return self.mainVBox + #end def get_vbox + + def showClicked(self, widget, data): + try: self.canvas.destroy() + except AttributeError: pass + + name=self.nameEntry.get_text() + + site=self.siteEntry.get_text() + + if site=="PS": + site=2 + sitename="PokerStars: " + elif site=="FTP": + site=1 + sitename="Full Tilt: " + else: + print "invalid text in site selection in graph, defaulting to PS" + site=2 + + self.fig = Figure(figsize=(5,4), dpi=100) + + #Set graph properties + self.ax = self.fig.add_subplot(111) + + # + self.ax.set_title("Profit graph for ring games") + + #Set axis labels and grid overlay properites + self.ax.set_xlabel("Hands", fontsize = 12) + self.ax.set_ylabel("$", fontsize = 12) + self.ax.grid(color='g', linestyle=':', linewidth=0.2) + text = "All Hands, " + sitename + str(name) + + self.ax.annotate (text, (61,25), xytext =(0.1, 0.9) , textcoords ="axes fraction" ,) + + #Get graph data from DB + line = self.getRingProfitGraph(name, site) + + #Draw plot + self.ax.plot(line,) + + self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea + self.mainVBox.pack_start(self.canvas) + self.canvas.show() + #end of def showClicked + + def getRingProfitGraph(self, name, site): + self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site)) + winnings = self.db.cursor.fetchall() + + profit=range(len(winnings)) + for i in profit: + self.cursor.execute(self.sql.query['getRingProfitFromHandId'], (name, winnings[i][0], site)) + spent = self.db.cursor.fetchone() + profit[i]=(i, winnings[i][1]-spent[0]) + + y=map(lambda x:float(x[1]), profit) + line = cumsum(y) + return line/100 + #end of def getRingProfitGraph + + def __init__(self, db, settings, querylist, config, debug=True): + """Constructor for GraphViewer""" + self.debug=debug + #print "start of GraphViewer constructor" + self.db=db + self.cursor=db.cursor + self.settings=settings + self.sql=querylist + + self.mainVBox = gtk.VBox(False, 0) + self.mainVBox.show() + + self.settingsHBox = gtk.HBox(False, 0) + self.mainVBox.pack_start(self.settingsHBox, False, True, 0) + self.settingsHBox.show() + + self.nameLabel = gtk.Label("Name of the player to be graphed:") + self.settingsHBox.pack_start(self.nameLabel) + self.nameLabel.show() + + self.nameEntry=gtk.Entry() + self.nameEntry.set_text("name") + self.settingsHBox.pack_start(self.nameEntry) + self.nameEntry.show() + + self.siteLabel = gtk.Label("Site (PS or FTP):") + self.settingsHBox.pack_start(self.siteLabel) + self.siteLabel.show() + + self.siteEntry=gtk.Entry() + self.siteEntry.set_text("PS") + self.settingsHBox.pack_start(self.siteEntry) + self.siteEntry.show() + + #Note: Assumes PokerStars is in the config + self.nameEntry.set_text(config.supported_sites["PokerStars"].screen_name) + + self.showButton=gtk.Button("Show/Refresh") + self.showButton.connect("clicked", self.showClicked, "show clicked") + self.settingsHBox.pack_start(self.showButton) + self.showButton.show() + #end of GuiGraphViewer.__init__ diff --git a/pyfpdb/GuiTableViewer.py b/pyfpdb/GuiTableViewer.py new file mode 100644 index 00000000..f024a193 --- /dev/null +++ b/pyfpdb/GuiTableViewer.py @@ -0,0 +1,309 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import threading +import pygtk +pygtk.require('2.0') +import gtk +import os +import fpdb_simple + +try: + import MySQLdb +except: + diaSQLLibMissing = gtk.Dialog(title="Fatal Error - SQL interface library missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK)) + + label = gtk.Label("Please note that the table viewer only works with MySQL, if you use PostgreSQL this error is expected.") + diaSQLLibMissing.vbox.add(label) + label.show() + + label = gtk.Label("Since the HUD now runs on all supported plattforms I do not see any point in table viewer anymore, if you disagree please send a message to steffen@sycamoretest.info") + diaSQLLibMissing.vbox.add(label) + label.show() + + response = diaSQLLibMissing.run() + #sys.exit(1) + +import fpdb_import +import fpdb_db + +class GuiTableViewer (threading.Thread): + def hudDivide (self, a, b): + if b==0: + return "n/a" + else: + return str(int((a/float(b))*100))+"%" + #end def hudDivide + + def browse_clicked(self, widget, data): + """runs when user clicks browse on tv tab""" + #print "start of table_viewer.browser_clicked" + current_path=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter()) + + dia_chooser = gtk.FileChooserDialog(title="Please choose the file for which you want to open the Table Viewer", + action=gtk.FILE_CHOOSER_ACTION_OPEN, + buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + #dia_chooser.set_current_folder(pathname) + dia_chooser.set_filename(current_path) + #dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import + + response = dia_chooser.run() + if response == gtk.RESPONSE_OK: + #print dia_chooser.get_filename(), 'selected' + self.filename_tbuffer.set_text(dia_chooser.get_filename()) + elif response == gtk.RESPONSE_CANCEL: + print 'Closed, no files selected' + dia_chooser.destroy() + #end def table_viewer.browse_clicked + + def prepare_data(self): + """prepares the data for display by refresh_clicked, returns a 2D array""" + #print "start of prepare_data" + arr=[] + #first prepare the header row + if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"): + tmp=("Name", "HDs", "VPIP", "PFR", "PF3B4B", "ST") + + tmp+=("FS", "FB") + + tmp+=("CB", ) + + tmp+=("2B", "3B") + + tmp+=("AF", "FF", "AT", "FT", "AR", "FR") + + tmp+=("WtSD", "W$wsF", "W$SD") + else: + raise fpdb_simple.FpdbError("reimplement stud") + arr.append(tmp) + + #then the data rows + for player in range(len(self.player_names)): + tmp=[] + tmp.append(self.player_names[player][0]) + + seatCount=len(self.player_names) + if seatCount>=8: + minSeats,maxSeats=7,10 + elif seatCount==7: + minSeats,maxSeats=6,10 + elif seatCount==6 or seatCount==5: + minSeats,maxSeats=seatCount-1,seatCount+1 + elif seatCount==4: + minSeats,maxSeats=4,5 + elif seatCount==2 or seatCount==3: + minSeats,maxSeats=seatCount,seatCount + else: + fpdb_simple.FpdbError("invalid seatCount") + + self.cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats>=%s AND activeSeats<=%s", (self.gametype_id, self.player_ids[player][0], minSeats, maxSeats)) + rows=self.cursor.fetchall() + + row=[] + for field_no in range(len(rows[0])): + row.append(rows[0][field_no]) + + for row_no in range(len(rows)): + if row_no==0: + pass + else: + for field_no in range(len(rows[row_no])): + if field_no<=3: + pass + else: + #print "in prep data, row_no:",row_no,"field_no:",field_no + row[field_no]+=rows[row_no][field_no] + + tmp.append(str(row[6]))#Hands + tmp.append(self.hudDivide(row[7],row[6])) #VPIP + tmp.append(self.hudDivide(row[8],row[6])) #PFR + tmp.append(self.hudDivide(row[10],row[9])+" ("+str(row[9])+")") #PF3B4B + + tmp.append(self.hudDivide(row[31],row[30])+" ("+str(row[30])+")") #ST + + tmp.append(self.hudDivide(row[35],row[34])+" ("+str(row[34])+")") #FS + tmp.append(self.hudDivide(row[33],row[32])+" ("+str(row[32])+")") #FB + + tmp.append(self.hudDivide(row[37],row[36])+" ("+str(row[36])+")") #CB + + tmp.append(self.hudDivide(row[39],row[38])+" ("+str(row[38])+")") #2B + tmp.append(self.hudDivide(row[41],row[40])+" ("+str(row[40])+")") #3B + + tmp.append(self.hudDivide(row[16],row[11])+" ("+str(row[11])+")") #AF + tmp.append(self.hudDivide(row[24],row[20])+" ("+str(row[20])+")") #FF + tmp.append(self.hudDivide(row[17],row[12])+" ("+str(row[12])+")") #AT + tmp.append(self.hudDivide(row[25],row[21])+" ("+str(row[21])+")") #FT + tmp.append(self.hudDivide(row[18],row[13])+" ("+str(row[13])+")") #AR + tmp.append(self.hudDivide(row[26],row[22])+" ("+str(row[22])+")") #FR + + tmp.append(self.hudDivide(row[15],row[11])) #WtSD + tmp.append(self.hudDivide(row[28],row[11])) #W$wSF + tmp.append(self.hudDivide(row[29],row[15])+" ("+str(row[15])+")") #W$@SD + + arr.append(tmp) + return arr + #end def table_viewer.prepare_data + + def refresh_clicked(self, widget, data): + """runs when user clicks refresh""" + #print "start of table_viewer.refresh_clicked" + arr=self.prepare_data() + + try: self.data_table.destroy() + except AttributeError: pass + self.data_table=gtk.Table(rows=len(arr), columns=len(arr[0]), homogeneous=False) + self.main_vbox.pack_start(self.data_table) + self.data_table.show() + + for row in range(len(arr)): + for column in range (len(arr[row])): + eventBox=gtk.EventBox() + new_label=gtk.Label(arr[row][column]) + if row%2==0: # + bg_col="white" + if column==0 or (column>=5 and column<=10): + bg_col="lightgrey" + else: + bg_col="lightgrey" + if column==0 or (column>=5 and column<=10): + bg_col="grey" + #style = eventBox.get_style() + #style.font.height=8 + #eventBox.set_style(style) + + eventBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bg_col)) + eventBox.add(new_label) + self.data_table.attach(child=eventBox, left_attach=column, right_attach=column+1, top_attach=row, bottom_attach=row+1) + eventBox.show() + new_label.show() + #end def table_viewer.refresh_clicked + + def read_names_clicked(self, widget, data): + """runs when user clicks read names""" + #print "start of table_viewer.read_names_clicked" + self.db.reconnect() + self.cursor=self.db.cursor + #self.hands_id=self.last_read_hand_id + + self.db.cursor.execute("SELECT gametypeId FROM Hands WHERE id=%s", (self.hands_id, )) + self.gametype_id=self.db.cursor.fetchone()[0] + self.cursor.execute("SELECT category FROM Gametypes WHERE id=%s", (self.gametype_id, )) + self.category=self.db.cursor.fetchone()[0] + #print "self.gametype_id", self.gametype_id," category:", self.category, " self.hands_id:", self.hands_id + + self.db.cursor.execute("""SELECT DISTINCT Players.id FROM HandsPlayers + INNER JOIN Players ON HandsPlayers.playerId=Players.id + WHERE handId=%s""", (self.hands_id, )) + self.player_ids=self.db.cursor.fetchall() + #print "self.player_ids:",self.player_ids + + self.db.cursor.execute("""SELECT DISTINCT Players.name FROM HandsPlayers + INNER JOIN Players ON HandsPlayers.playerId=Players.id + WHERE handId=%s""", (self.hands_id, )) + self.player_names=self.db.cursor.fetchall() + #print "self.player_names:",self.player_names + #end def table_viewer.read_names_clicked + + def import_clicked(self, widget, data): + """runs when user clicks import""" + #print "start of table_viewer.import_clicked" + self.inputFile=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter()) + + self.server=self.db.host + self.database=self.db.database + self.user=self.db.user + self.password=self.db.password + + self.importer = fpdb_import.Importer(self, self.settings) + self.importer.setMinPrint(0) + self.importer.setQuiet(False) + self.importer.setFailOnError(False) + self.importer.setHandCount(0) + + self.importer.addImportFile(self.inputFile) + self.importer.runImport() + self.hands_id=self.importer.handsId + #end def table_viewer.import_clicked + + def all_clicked(self, widget, data): + """runs when user clicks all""" + #print "start of table_viewer.all_clicked" + self.import_clicked(widget, data) + self.read_names_clicked(widget, data) + self.refresh_clicked(widget, data) + #end def table_viewer.all_clicked + + def get_vbox(self): + """returns the vbox of this thread""" + return self.main_vbox + #end def get_vbox + + def __init__(self, db, settings, debug=True): + """Constructor for table_viewer""" + self.debug=debug + #print "start of table_viewer constructor" + self.db=db + self.cursor=db.cursor + self.settings=settings + + self.main_vbox = gtk.VBox(False, 0) + self.main_vbox.show() + + self.settings_hbox = gtk.HBox(False, 0) + self.main_vbox.pack_end(self.settings_hbox, False, True, 0) + self.settings_hbox.show() + + self.filename_label = gtk.Label("Path of history file") + self.settings_hbox.pack_start(self.filename_label, False, False) + self.filename_label.show() + + self.filename_tbuffer=gtk.TextBuffer() + self.filename_tbuffer.set_text(self.settings['hud-defaultPath']) + self.filename_tview=gtk.TextView(self.filename_tbuffer) + self.settings_hbox.pack_start(self.filename_tview, True, True, padding=5) + self.filename_tview.show() + + self.browse_button=gtk.Button("Browse...") + self.browse_button.connect("clicked", self.browse_clicked, "Browse clicked") + self.settings_hbox.pack_start(self.browse_button, False, False) + self.browse_button.show() + + + self.button_hbox = gtk.HBox(False, 0) + self.main_vbox.pack_end(self.button_hbox, False, True, 0) + self.button_hbox.show() + + #self.import_button = gtk.Button("Import") + #self.import_button.connect("clicked", self.import_clicked, "Import clicked") + #self.button_hbox.add(self.import_button) + #self.import_button.show() + + #self.read_names_button = gtk.Button("Read Names") + #self.read_names_button.connect("clicked", self.read_names_clicked, "Read clicked") + #self.button_hbox.add(self.read_names_button) + #self.read_names_button.show() + + #self.refresh_button = gtk.Button("Show/Refresh data") + #self.refresh_button.connect("clicked", self.refresh_clicked, "Refresh clicked") + #self.button_hbox.add(self.refresh_button) + #self.refresh_button.show() + + self.all_button = gtk.Button("Import&Read&Refresh") + self.all_button.connect("clicked", self.all_clicked, "All clicked") + self.button_hbox.add(self.all_button) + self.all_button.show() + #end of table_viewer.__init__ diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example new file mode 100644 index 00000000..3a595fe2 --- /dev/null +++ b/pyfpdb/HUD_config.xml.example @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py new file mode 100755 index 00000000..f54fa9af --- /dev/null +++ b/pyfpdb/HUD_main.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python + +"""Hud_main.py + +Main for FreePokerTools HUD. +""" +# Copyright 2008, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# to do kill window on my seat +# to do adjust for preferred seat +# to do allow window resizing +# to do hud to echo, but ignore non numbers +# to do no hud window for hero +# to do things to add to config.xml +# to do font and size +# to do opacity + +# Standard Library modules +import sys +import os +import thread +import time +import string +import re + +errorfile = open('HUD-error.txt', 'w', 0) +sys.stderr = errorfile + +# pyGTK modules +import pygtk +import gtk +import gobject + +# FreePokerTools modules +import Configuration +import Database +import Tables +import Hud + +# global dict for keeping the huds +hud_dict = {} + +db_connection = 0; +config = 0; + +def destroy(*args): # call back for terminating the main eventloop + gtk.main_quit() + +def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_connection, config, stat_dict): + global hud_dict + def idle_func(): + global hud_dict + gtk.gdk.threads_enter() + try: + hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name) + hud_dict[table_name].create(new_hand_id, config) + hud_dict[table_name].update(new_hand_id, config, stat_dict) + hud_dict[table_name].reposition_windows() + return False + finally: + gtk.gdk.threads_leave() + gobject.idle_add(idle_func) + +def update_HUD(new_hand_id, table_name, config, stat_dict): + global hud_dict + def idle_func(): + gtk.gdk.threads_enter() + try: + hud_dict[table_name].update(new_hand_id, config, stat_dict) + return False + finally: + gtk.gdk.threads_leave() + gobject.idle_add(idle_func) + +def read_stdin(): # This is the thread function + global hud_dict + + db_connection = Database.Database(config, db_name, 'temp') +# tourny_finder = re.compile('(\d+) (\d+)') + + while True: # wait for a new hand number on stdin + new_hand_id = sys.stdin.readline() + new_hand_id = string.rstrip(new_hand_id) + if new_hand_id == "": # blank line means quit + destroy() + +# delete hud_dict entries for any HUD destroyed since last iteration + for h in hud_dict.keys(): + if hud_dict[h].deleted: + del(hud_dict[h]) + +# get basic info about the new hand from the db + (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) + +# find out if this hand is from a tournament + is_tournament = False +# (t_number, s_number) = (0, 0) +# mat_obj = tourny_finder(table_name) +# if len(mat_obj.groups) == 2: +# is_tournament = True +# (t_number, s_number) = mat_obj.group(1, 2) + + stat_dict = db_connection.get_stats_from_hand(new_hand_id) + +# if a hud for this CASH table exists, just update it + if hud_dict.has_key(table_name): + update_HUD(new_hand_id, table_name, config, stat_dict) +# if a hud for this TOURNAMENT table exists, just update it +# elif hud_dict.has_key(t_number): +# update_HUD(new_hand_id, t_number, config, stat_dict) +# otherwise create a new hud + else: + if is_tournament: + tablewindow = Tables.discover_tournament_table(config, t_number, s_number) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, t_number, max, poker_game, db_connection, config, stat_dict) + else: + tablewindow = Tables.discover_table_by_name(config, table_name) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict) + +if __name__== "__main__": + sys.stderr.write("HUD_main starting\n") + + try: + db_name = sys.argv[1] + except: + db_name = 'fpdb' + sys.stderr.write("Using db name = %s\n" % (db_name)) + + config = Configuration.Config() + + gobject.threads_init() # this is required + thread.start_new_thread(read_stdin, ()) # starts the thread + + main_window = gtk.Window() + main_window.connect("destroy", destroy) + eb = gtk.EventBox() + label = gtk.Label('Closing this window will exit from the HUD.') + eb.add(label) + main_window.add(eb) + main_window.set_title("HUD Main Window") + main_window.show_all() + + gtk.main() + diff --git a/pyfpdb/HandHistory.py b/pyfpdb/HandHistory.py new file mode 100644 index 00000000..dd2fa427 --- /dev/null +++ b/pyfpdb/HandHistory.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python +"""HandHistory.py + +Parses HandHistory xml files and returns requested objects. +""" +# Copyright 2008, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## +# Standard Library modules +import xml.dom.minidom +from xml.dom.minidom import Node + +class HandHistory: + def __init__(self, xml_string, elements = ('ALL')): + + doc = xml.dom.minidom.parseString(xml_string) + if elements == ('ALL'): + elements = ('BETTING', 'AWARDS', 'POSTS', 'PLAYERS', 'GAME') + + if 'BETTING' in elements: + self.BETTING = Betting(doc.getElementsByTagName('BETTING')[0]) + if 'AWARDS' in elements: + self.AWARDS = Awards (doc.getElementsByTagName('AWARDS')[0]) + if 'POSTS' in elements: + self.POSTS = Posts (doc.getElementsByTagName('POSTS')[0]) + if 'GAME' in elements: + self.GAME = Game (doc.getElementsByTagName('GAME')[0]) + if 'PLAYERS' in elements: + self.PLAYERS = {} + p_n = doc.getElementsByTagName('PLAYERS')[0] + for p in p_n.getElementsByTagName('PLAYER'): + a_player = Player(p) + self.PLAYERS[a_player.name] = a_player + +class Player: + def __init__(self, node): + self.name = node.getAttribute('NAME') + self.seat = node.getAttribute('SEAT') + self.stack = node.getAttribute('STACK') + self.showed_hand = node.getAttribute('SHOWED_HAND') + self.cards = node.getAttribute('CARDS') + self.allin = node.getAttribute('ALLIN') + self.sitting_out = node.getAttribute('SITTING_OUT') + self.hand = node.getAttribute('HAND') + self.start_cards = node.getAttribute('START_CARDS') + + if self.allin == '' or \ + self.allin == '0' or \ + self.allin.upper() == 'FALSE': self.allin = False + else: self.allin = True + + if self.sitting_out == '' or \ + self.sitting_out == '0' or \ + self.sitting_out.upper() == 'FALSE': self.sitting_out = False + else: self.sitting_out = True + + def __str__(self): + temp = "%s\n seat = %s\n stack = %s\n cards = %s\n" % \ + (self.name, self.seat, self.stack, self.cards) + temp = temp + " showed_hand = %s\n allin = %s\n" % \ + (self.showed_hand, self.allin) + temp = temp + " hand = %s\n start_cards = %s\n" % \ + (self.hand, self.start_cards) + return temp + +class Awards: + def __init__(self, node): + self.awards = [] # just an array of award objects + for a in node.getElementsByTagName('AWARD'): + self.awards.append(Award(a)) + + def __str__(self): + temp = "" + for a in self.awards: + temp = temp + "%s\n" % (a) + return temp + +class Award: + def __init__(self, node): + self.player = node.getAttribute('PLAYER') + self.amount = node.getAttribute('AMOUNT') + self.pot = node.getAttribute('POT') + + def __str__(self): + return self.player + " won " + self.amount + " from " + self.pot + +class Game: + def __init__(self, node): + print node + self.tags = {} + for tag in ( ('GAME_NAME', 'game_name'), ('MAX', 'max'), ('HIGHLOW', 'high_low'), + ('STRUCTURE', 'structure'), ('MIXED', 'mixed') ): + L = node.getElementsByTagName(tag[0]) + if (not L): continue + print L + for node2 in L: + title = "" + for node3 in node2.childNodes: + if (node3.nodeType == Node.TEXT_NODE): + title +=node3.data + self.tags[tag[1]] = title + + def __str__(self): + return "%s %s %s, (%s max), %s" % (self.tags['structure'], + self.tags['game_name'], + self.tags['game_name'], + self.tags['max'], + self.tags['game_name']) + +class Posts: + def __init__(self, node): + self.posts = [] # just an array of post objects + for p in node.getElementsByTagName('POST'): + self.posts.append(Post(p)) + + def __str__(self): + temp = "" + for p in self.posts: + temp = temp + "%s\n" % (p) + return temp + +class Post: + def __init__(self, node): + self.player = node.getAttribute('PLAYER') + self.amount = node.getAttribute('AMOUNT') + self.posted = node.getAttribute('POSTED') + self.live = node.getAttribute('LIVE') + + def __str__(self): + return ("%s posted %s %s %s") % (self.player, self.amount, self.posted, self.live) + +class Betting: + def __init__(self, node): + self.rounds = [] # a Betting object is just an array of rounds + for r in node.getElementsByTagName('ROUND'): + self.rounds.append(Round(r)) + + def __str__(self): + temp = "" + for r in self.rounds: + temp = temp + "%s\n" % (r) + return temp + +class Round: + def __init__(self, node): + self.name = node.getAttribute('ROUND_NAME') + self.action = [] + for a in node.getElementsByTagName('ACTION'): + self.action.append(Action(a)) + + def __str__(self): + temp = self.name + "\n" + for a in self.action: + temp = temp + " %s\n" % (a) + return temp + +class Action: + def __init__(self, node): + self.player = node.getAttribute('PLAYER') + self.action = node.getAttribute('ACT') + self.amount = node.getAttribute('AMOUNT') + self.allin = node.getAttribute('ALLIN') + + def __str__(self): + return self.player + " " + self.action + " " + self.amount + " " + self.allin + +if __name__== "__main__": + file = open('test.xml', 'r') + xml_string = file.read() + file.close() + + print xml_string + "\n\n\n" + h = HandHistory(xml_string, ('ALL')) + print h.GAME + print h.POSTS + print h.BETTING + print h.AWARDS + + for p in h.PLAYERS.keys(): + print h.PLAYERS[p] \ No newline at end of file diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py new file mode 100644 index 00000000..2490ad91 --- /dev/null +++ b/pyfpdb/Hud.py @@ -0,0 +1,562 @@ +#!/usr/bin/env python +"""Hud.py + +Create and manage the hud overlays. +""" +# Copyright 2008, Ray E. Barker + +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## +# Standard Library modules +import os +import sys + +# pyGTK modules +import pygtk +import gtk +import pango +import gobject + +# win32 modules -- only imported on windows systems +if os.name == 'nt': + import win32gui + import win32con + import win32api + +# FreePokerTools modules +import Tables # needed for testing only +import Configuration +import Stats +import Mucked +import Database +import HUD_main + +class Hud: + + def __init__(self, table, max, poker_game, config, db_name): + self.table = table + self.config = config + self.poker_game = poker_game + self.max = max + self.db_name = db_name + self.deleted = False + self.stacked = True + self.colors = config.get_default_colors(self.table.site) + + self.stat_windows = {} + self.popup_windows = {} + self.font = pango.FontDescription("Sans 8") + +# Set up a main window for this this instance of the HUD + self.main_window = gtk.Window() +# self.window.set_decorated(0) + self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC) + self.main_window.set_title(table.name + " FPDBHUD") + self.main_window.connect("destroy", self.kill_hud) + self.main_window.set_decorated(False) + #self.main_window.set_transient_for(parent.get_toplevel()) + + self.ebox = gtk.EventBox() + self.label = gtk.Label("Right click to close HUD for %s\nor Save Stat Positions." % (table.name)) + + self.label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor'])) + self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) + + self.main_window.add(self.ebox) + self.ebox.add(self.label) + self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor'])) + self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) + + self.main_window.move(self.table.x, self.table.y) + +# A popup window for the main window + self.menu = gtk.Menu() + self.item1 = gtk.MenuItem('Kill this HUD') + self.menu.append(self.item1) + self.item1.connect("activate", self.kill_hud) + self.item1.show() + self.item2 = gtk.MenuItem('Save Layout') + self.menu.append(self.item2) + self.item2.connect("activate", self.save_layout) + self.item2.show() + self.item3 = gtk.MenuItem('Reposition Stats') + self.menu.append(self.item3) + self.item3.connect("activate", self.reposition_windows) + self.item3.show() + self.ebox.connect_object("button-press-event", self.on_button_press, self.menu) + + self.main_window.show_all() +# set_keep_above(1) for windows + if os.name == 'nt': + self.topify_window(self.main_window) + else: + self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) # gets a gdk handle for poker client + self.main_window.gdkhandle = gtk.gdk.window_foreign_new(self.main_window.window.xid) # gets a gdk handle for the hud table window + self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) # + + self.main_window.set_destroy_with_parent(True) + + def on_button_press(self, widget, event): + if event.button == 3: + widget.popup(None, None, None, event.button, event.time) + return True + return False + + def kill_hud(self, args): + for k in self.stat_windows.keys(): + self.stat_windows[k].window.destroy() + self.main_window.destroy() + self.deleted = True + + def reposition_windows(self, args): + for w in self.stat_windows: + self.stat_windows[w].window.move(self.stat_windows[w].x, + self.stat_windows[w].y) + def save_layout(self, *args): + new_layout = [] +# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. + for sw in self.stat_windows: + loc = self.stat_windows[sw].window.get_position() + new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) + new_layout.append(new_loc) +# print new_layout + self.config.edit_layout(self.table.site, self.max, locations = new_layout) + self.config.save() + + def adj_seats(self, hand, config): + adj = range(0, self.max + 1) # default seat adjustments = no adjustment +# does the user have a fav_seat? + try: + if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: + fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat + db_connection = Database.Database(config, self.db_name, 'temp') + actual_seat = db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name) + db_connection.close_connection() + for i in range(0, self.max + 1): + j = actual_seat + i + if j > self.max: j = j - self.max + adj[j] = fav_seat + i + if adj[j] > self.max: adj[j] = adj[j] - self.max + except: + pass + return adj + + def create(self, hand, config): +# update this hud, to the stats and players as of "hand" +# hand is the hand id of the most recent hand played at this table +# +# this method also manages the creating and destruction of stat +# windows via calls to the Stat_Window class + + adj = self.adj_seats(hand, config) + loc = self.config.get_locations(self.table.site, self.max) + +# create the stat windows + for i in range(1, self.max + 1): + (x, y) = loc[adj[i]] + if self.stat_windows.has_key(i): + self.stat_windows[i].relocate(x, y) + else: + self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game], + parent = self, + table = self.table, + x = x, + y = y, + seat = i, + player_id = 'fake', + font = self.font) + + self.stats = [] + for i in range(0, config.supported_games[self.poker_game].rows + 1): + row_list = [''] * config.supported_games[self.poker_game].cols + self.stats.append(row_list) + for stat in config.supported_games[self.poker_game].stats.keys(): + self.stats[config.supported_games[self.poker_game].stats[stat].row] \ + [config.supported_games[self.poker_game].stats[stat].col] = \ + config.supported_games[self.poker_game].stats[stat].stat_name +# self.mucked_window = gtk.Window() +# self.m = Mucked.Mucked(self.mucked_window, self.db_connection) +# self.mucked_window.show_all() + + def update(self, hand, config, stat_dict): + self.hand = hand # this is the last hand, so it is available later + for s in stat_dict.keys(): + try: + self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] + except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here + self.max = 10 + self.create(hand, config) + self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] + + for r in range(0, config.supported_games[self.poker_game].rows): + for c in range(0, config.supported_games[self.poker_game].cols): + this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]] + number = Stats.do_stat(stat_dict, player = stat_dict[s]['player_id'], stat = self.stats[r][c]) + statstring = this_stat.hudprefix + str(number[1]) + this_stat.hudsuffix + self.stat_windows[stat_dict[s]['seat']].label[r][c].set_text(statstring) + tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ + number[3] + ", " + number[4] + Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip) +# self.m.update(hand) + + def topify_window(self, window): + """Set the specified gtk window to stayontop in MS Windows.""" + + def windowEnumerationHandler(hwnd, resultList): + '''Callback for win32gui.EnumWindows() to generate list of window handles.''' + resultList.append((hwnd, win32gui.GetWindowText(hwnd))) + + unique_name = 'unique name for finding this window' + real_name = window.get_title() + window.set_title(unique_name) + tl_windows = [] + win32gui.EnumWindows(windowEnumerationHandler, tl_windows) + + for w in tl_windows: + if w[1] == unique_name: + #win32gui.ShowWindow(w[0], win32con.SW_HIDE) + window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) + self.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) + self.main_window.gdkhandle.set_transient_for(window.parentgdkhandle) + #win32gui.ShowWindow(w[0], win32con.SW_SHOW) + + style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) + #style |= win32con.WS_EX_TOOLWINDOW + #style &= ~win32con.WS_EX_APPWINDOW + style |= win32con.WS_CLIPCHILDREN + win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style) + + + #win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE) + +# notify_id = (w[0], +# 0, +# win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP, +# win32con.WM_USER+20, +# 0, +# '') +# win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, notify_id) +# + window.set_title(real_name) + +class Stat_Window: + + def button_press_cb(self, widget, event, *args): +# This handles all callbacks from button presses on the event boxes in +# the stat windows. There is a bit of an ugly kludge to separate single- +# and double-clicks. + if event.button == 1: # left button event + if event.type == gtk.gdk.BUTTON_PRESS: # left button single click + if self.sb_click > 0: return + self.sb_click = gobject.timeout_add(250, self.single_click, widget) + elif event.type == gtk.gdk._2BUTTON_PRESS: # left button double click + if self.sb_click > 0: + gobject.source_remove(self.sb_click) + self.sb_click = 0 + self.double_click(widget, event, *args) + + if event.button == 2: # middle button event + pass +# print "middle button clicked" + + if event.button == 3: # right button event + pass +# print "right button clicked" + + def single_click(self, widget): +# Callback from the timeout in the single-click finding part of the +# button press call back. This needs to be modified to get all the +# arguments from the call. +# print "left button clicked" + self.sb_click = 0 + Popup_window(widget, self) + return False + + def double_click(self, widget, event, *args): + self.toggle_decorated(widget) + + def toggle_decorated(self, widget): + top = widget.get_toplevel() + (x, y) = top.get_position() + + if top.get_decorated(): + top.set_decorated(0) + top.move(x, y) + else: + top.set_decorated(1) + top.move(x, y) + + def relocate(self, x, y): + self.x = x + self.table.x + self.y = y + self.table.y + self.window.move(self.x, self.y) + + def __init__(self, parent, game, table, seat, x, y, player_id, font): + self.parent = parent # Hud object that this stat window belongs to + self.game = game # Configuration object for the curren + self.table = table # Table object where this is going + self.x = x + table.x # table.x and y are the location of the table + self.y = y + table.y # x and y are the location relative to table.x & y + self.player_id = player_id # looks like this isn't used ;) + self.sb_click = 0 # used to figure out button clicks + + self.window = gtk.Window() + self.window.set_decorated(0) + self.window.set_gravity(gtk.gdk.GRAVITY_STATIC) + + self.window.set_title("%s" % seat) + self.window.set_property("skip-taskbar-hint", True) + self.window.set_transient_for(parent.main_window) + + self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False) + self.window.add(self.grid) + + self.e_box = [] + self.frame = [] + self.label = [] + for r in range(self.game.rows): + self.e_box.append([]) + self.label.append([]) + for c in range(self.game.cols): + self.e_box[r].append( gtk.EventBox() ) + + self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor'])) + self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor'])) + + Stats.do_tip(self.e_box[r][c], 'farts') + self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) + self.label[r].append( gtk.Label('xxx') ) + + self.label[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor'])) + self.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor'])) + + self.e_box[r][c].add(self.label[r][c]) + self.e_box[r][c].connect("button_press_event", self.button_press_cb) +# font = pango.FontDescription("Sans 8") + self.label[r][c].modify_font(font) + + if not os.name == 'nt': # seems to be a bug in opacity on windows + self.window.set_opacity(parent.colors['hudopacity']) + self.window.realize + self.window.move(self.x, self.y) + self.window.show_all() +# set_keep_above(1) for windows + if os.name == 'nt': self.topify_window(self.window) + + def topify_window(self, window): + """Set the specified gtk window to stayontop in MS Windows.""" + + def windowEnumerationHandler(hwnd, resultList): + '''Callback for win32gui.EnumWindows() to generate list of window handles.''' + resultList.append((hwnd, win32gui.GetWindowText(hwnd))) + + unique_name = 'unique name for finding this window' + real_name = window.get_title() + window.set_title(unique_name) + tl_windows = [] + win32gui.EnumWindows(windowEnumerationHandler, tl_windows) + + for w in tl_windows: + if w[1] == unique_name: + + #win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE) + +# style = win32gui.GetWindowLong(w[0], win32con.GWL_EXSTYLE) +# style |= win32con.WS_EX_TOOLWINDOW +# style &= ~win32con.WS_EX_APPWINDOW +# win32gui.SetWindowLong(w[0], win32con.GWL_EXSTYLE, style) + win32gui.ShowWindow(w[0], win32con.SW_SHOW) + window.set_title(real_name) + +def destroy(*args): # call back for terminating the main eventloop + gtk.main_quit() + +class Popup_window: + def __init__(self, parent, stat_window): + self.sb_click = 0 + +# create the popup window + self.window = gtk.Window() + self.window.set_decorated(0) + self.window.set_gravity(gtk.gdk.GRAVITY_STATIC) +# self.window.set_keep_above(1) + self.window.set_title("popup") + self.window.set_property("skip-taskbar-hint", True) + self.window.set_transient_for(parent.get_toplevel()) + + self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + + self.ebox = gtk.EventBox() + self.ebox.connect("button_press_event", self.button_press_cb) + self.lab = gtk.Label("stuff\nstuff\nstuff") + +# need an event box so we can respond to clicks + self.window.add(self.ebox) + self.ebox.add(self.lab) + + self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) + self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) + self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) + self.window.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) + self.lab.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) + self.lab.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) + + self.window.realize + +# figure out the row, col address of the click that activated the popup + row = 0 + col = 0 + for r in range(0, stat_window.game.rows): + for c in range(0, stat_window.game.cols): + if stat_window.e_box[r][c] == parent: + row = r + col = c + break + +# figure out what popup format we're using + popup_format = "default" + for stat in stat_window.game.stats.keys(): + if stat_window.game.stats[stat].row == row and stat_window.game.stats[stat].col == col: + popup_format = stat_window.game.stats[stat].popup + break + +# get the list of stats to be presented from the config + stat_list = [] + for w in stat_window.parent.config.popup_windows.keys(): + if w == popup_format: + stat_list = stat_window.parent.config.popup_windows[w].pu_stats + break + +# get a database connection + db_connection = Database.Database(stat_window.parent.config, stat_window.parent.db_name, 'temp') + +# calculate the stat_dict and then create the text for the pu +# stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand, stat_window.player_id) + stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand) + db_connection.close_connection() + + pu_text = "" + for s in stat_list: + number = Stats.do_stat(stat_dict, player = int(stat_window.player_id), stat = s) + pu_text += number[3] + "\n" + + self.lab.set_text(pu_text) + self.window.show_all() + + self.window.set_transient_for(stat_window.main_window) + +# set_keep_above(1) for windows + if os.name == 'nt': self.topify_window(self.window) + + def button_press_cb(self, widget, event, *args): +# This handles all callbacks from button presses on the event boxes in +# the popup windows. There is a bit of an ugly kludge to separate single- +# and double-clicks. This is the same code as in the Stat_window class + if event.button == 1: # left button event + if event.type == gtk.gdk.BUTTON_PRESS: # left button single click + if self.sb_click > 0: return + self.sb_click = gobject.timeout_add(250, self.single_click, widget) + elif event.type == gtk.gdk._2BUTTON_PRESS: # left button double click + if self.sb_click > 0: + gobject.source_remove(self.sb_click) + self.sb_click = 0 + self.double_click(widget, event, *args) + + if event.button == 2: # middle button event + pass +# print "middle button clicked" + + if event.button == 3: # right button event + pass +# print "right button clicked" + + def single_click(self, widget): +# Callback from the timeout in the single-click finding part of the +# button press call back. This needs to be modified to get all the +# arguments from the call. + self.sb_click = 0 + self.window.destroy() + return False + + def double_click(self, widget, event, *args): + self.toggle_decorated(widget) + + def toggle_decorated(self, widget): + top = widget.get_toplevel() + (x, y) = top.get_position() + + if top.get_decorated(): + top.set_decorated(0) + top.move(x, y) + else: + top.set_decorated(1) + top.move(x, y) + + def topify_window(self, window): + """Set the specified gtk window to stayontop in MS Windows.""" + + def windowEnumerationHandler(hwnd, resultList): + '''Callback for win32gui.EnumWindows() to generate list of window handles.''' + resultList.append((hwnd, win32gui.GetWindowText(hwnd))) + + unique_name = 'unique name for finding this window' + real_name = window.get_title() + window.set_title(unique_name) + tl_windows = [] + win32gui.EnumWindows(windowEnumerationHandler, tl_windows) + + for w in tl_windows: + if w[1] == unique_name: +# win32gui.ShowWindow(w[0], win32con.SW_HIDE) +# style = win32gui.GetWindowLong(w[0], win32con.GWL_EXSTYLE) +# style |= win32con.WS_EX_TOOLWINDOW +# style &= ~win32con.WS_EX_APPWINDOW +# win32gui.SetWindowLong(w[0], win32con.GWL_EXSTYLE, style) +# win32gui.ShowWindow(w[0], win32con.SW_SHOW) + win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE) + +# notify_id = (w[0], +# 0, +# win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP, +# win32con.WM_USER+20, +# 0, +# '') +# win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, notify_id) +# + window.set_title(real_name) + +if __name__== "__main__": + main_window = gtk.Window() + main_window.connect("destroy", destroy) + label = gtk.Label('Fake main window, blah blah, blah\nblah, blah') + main_window.add(label) + main_window.show_all() + + c = Configuration.Config() + #tables = Tables.discover(c) + t = Tables.discover_table_by_name(c, "Chelsea") + if t is None: + print "Table not found." + db = Database.Database(c, 'fpdb', 'holdem') + +# for t in tables: + win = Hud(t, 10, 'holdem', c, db) + win.create(1, c) +# t.get_details() + win.update(8300, db, c) + + gtk.main() diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py new file mode 100644 index 00000000..0af06c65 --- /dev/null +++ b/pyfpdb/Mucked.py @@ -0,0 +1,243 @@ +#!/usr/bin/env python +"""Mucked.py + +Mucked cards display for FreePokerTools HUD. +""" +# Copyright 2008, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# to do +# problem with hand 30586 + +# Standard Library modules +import sys +import os +import string +import xml.dom.minidom +from xml.dom.minidom import Node + +# pyGTK modules +import pygtk +import gtk +import gobject + +# FreePokerTools modules +import Configuration +import Database +import Tables +import Hud +import Mucked +import HandHistory + +class Mucked: + def __init__(self, parent, db_connection): + + self.parent = parent #this is the parent of the mucked cards widget + self.db_connection = db_connection + + self.vbox = gtk.VBox() + self.parent.add(self.vbox) + + self.mucked_list = MuckedList (self.vbox, db_connection) + self.mucked_cards = MuckedCards(self.vbox, db_connection) + self.mucked_list.mucked_cards = self.mucked_cards + + def update(self, new_hand_id): + self.mucked_list.update(new_hand_id) + +class MuckedList: + def __init__(self, parent, db_connection): + + self.parent = parent + self.db_connection = db_connection + +# set up a scrolled window to hold the listbox + self.scrolled_window = gtk.ScrolledWindow() + self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) + self.parent.add(self.scrolled_window) + +# create a ListStore to use as the model + self.liststore = gtk.ListStore(str, str, str) + self.treeview = gtk.TreeView(self.liststore) + self.tvcolumn0 = gtk.TreeViewColumn('HandID') + self.tvcolumn1 = gtk.TreeViewColumn('Cards') + self.tvcolumn2 = gtk.TreeViewColumn('Net') + +# add tvcolumn to treeview + self.treeview.append_column(self.tvcolumn0) + self.treeview.append_column(self.tvcolumn1) + self.treeview.append_column(self.tvcolumn2) + +# create a CellRendererText to render the data + self.cell = gtk.CellRendererText() + + # add the cell to the tvcolumn and allow it to expand + self.tvcolumn0.pack_start(self.cell, True) + self.tvcolumn1.pack_start(self.cell, True) + self.tvcolumn2.pack_start(self.cell, True) + self.tvcolumn0.add_attribute(self.cell, 'text', 0) + self.tvcolumn1.add_attribute(self.cell, 'text', 1) + self.tvcolumn2.add_attribute(self.cell, 'text', 2) +# resize the cols if nec + self.tvcolumn0.set_resizable(True) + self.treeview.connect("row-activated", self.activated_event) + + self.scrolled_window.add_with_viewport(self.treeview) + + def activated_event(self, path, column, data=None): + sel = self.treeview.get_selection() + (model, iter) = sel.get_selected() + self.mucked_cards.update(model.get_value(iter, 0)) + + def update(self, new_hand_id): +# info_row = self.db_connection.get_hand_info(new_hand_id) + info_row = ((new_hand_id, "xxxx", 0), ) + iter = self.liststore.append(info_row[0]) + sel = self.treeview.get_selection() + sel.select_iter(iter) + + vadj = self.scrolled_window.get_vadjustment() + vadj.set_value(vadj.upper) + self.mucked_cards.update(new_hand_id) + +class MuckedCards: + def __init__(self, parent, db_connection): + + self.parent = parent #this is the parent of the mucked cards widget + self.db_connection = db_connection + + self.card_images = self.get_card_images() + self.seen_cards = {} + self.grid_contents = {} + self.eb = {} + + self.rows = 8 + self.cols = 7 + self.grid = gtk.Table(self.rows, self.cols + 4, homogeneous = False) + + for r in range(0, self.rows): + for c in range(0, self.cols): + self.seen_cards[(c, r)] = gtk.image_new_from_pixbuf(self.card_images[('B', 'S')]) + self.eb[(c, r)]= gtk.EventBox() + +# set up the contents for the cells + for r in range(0, self.rows): + self.grid_contents[( 0, r)] = gtk.Label("%d" % (r + 1)) + self.grid_contents[( 1, r)] = gtk.Label("player %d" % (r + 1)) + self.grid_contents[( 4, r)] = gtk.Label("-") + self.grid_contents[( 9, r)] = gtk.Label("-") + self.grid_contents[( 2, r)] = self.eb[( 0, r)] + self.grid_contents[( 3, r)] = self.eb[( 1, r)] + self.grid_contents[( 5, r)] = self.eb[( 2, r)] + self.grid_contents[( 6, r)] = self.eb[( 3, r)] + self.grid_contents[( 7, r)] = self.eb[( 4, r)] + self.grid_contents[( 8, r)] = self.eb[( 5, r)] + self.grid_contents[(10, r)] = self.eb[( 6, r)] + for c in range(0, self.cols): + self.eb[(c, r)].add(self.seen_cards[(c, r)]) + +# add the cell contents to the table + for c in range(0, self.cols + 4): + for r in range(0, self.rows): + self.grid.attach(self.grid_contents[(c, r)], c, c+1, r, r+1, xpadding = 1, ypadding = 1) + + self.parent.add(self.grid) + + def translate_cards(self, old_cards): + pass + + def update(self, new_hand_id): + cards = self.db_connection.get_cards(new_hand_id) + self.clear() + + cards = self.translate_cards(cards) + for c in cards.keys(): + self.grid_contents[(1, cards[c]['seat_number'] - 1)].set_text(cards[c]['screen_name']) + + for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'), + (4, 'hole_card_5'), (5, 'hole_card_6'), (6, 'hole_card_7')): + if not cards[c][i[1]] == "": + self.seen_cards[(i[0], cards[c]['seat_number'] - 1)]. \ + set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])]) + + xml_text = self.db_connection.get_xml(new_hand_id) + hh = HandHistory.HandHistory(xml_text, ('BETTING')) + +# action in tool tips for 3rd street cards + tip = "%s" % hh.BETTING.rounds[0] + for c in (0, 1, 2): + for r in range(0, self.rows): + self.eb[(c, r)].set_tooltip_text(tip) + +# action in tools tips for later streets + round_to_col = (0, 3, 4, 5, 6) + for round in range(1, len(hh.BETTING.rounds)): + tip = "%s" % hh.BETTING.rounds[round] + for r in range(0, self.rows): + self.eb[(round_to_col[round], r)].set_tooltip_text(tip) + + def split_cards(self, card): + return (card[0], card[1].upper()) + + def clear(self): + for r in range(0, self.rows): + self.grid_contents[(1, r)].set_text(" ") + for c in range(0, 7): + self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')]) + self.eb[(c, r)].set_tooltip_text('') + def get_card_images(self): + card_images = {} + suits = ('S', 'H', 'D', 'C') + ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B') + pb = gtk.gdk.pixbuf_new_from_file("Cards01.png") + + for j in range(0, 14): + for i in range(0, 4): + temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42) + pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0) + card_images[(ranks[j], suits[i])] = temp_pb + return(card_images) + +# cards are 30 wide x 42 high + +if __name__== "__main__": + + def destroy(*args): # call back for terminating the main eventloop + gtk.main_quit() # used only for testing + + def process_new_hand(source, condition): #callback from stdin watch -- testing only +# there is a new hand_id to be processed +# just read it and pass it to update + new_hand_id = sys.stdin.readline() + new_hand_id = new_hand_id.rstrip() # remove trailing whitespace + m.update(new_hand_id) + return(True) + + config = Configuration.Config() + db_connection = Database.Database(config, 'fpdb', '') + + main_window = gtk.Window() + main_window.set_keep_above(True) + main_window.connect("destroy", destroy) + + m = Mucked(main_window, db_connection) + main_window.show_all() + + s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) + + gtk.main() diff --git a/pyfpdb/RegressionTest.py b/pyfpdb/RegressionTest.py new file mode 100644 index 00000000..b4dd1b7d --- /dev/null +++ b/pyfpdb/RegressionTest.py @@ -0,0 +1,87 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + + +############################################################################ +# +# File for Regression Testing fpdb +# + +import os +import sys + +import fpdb_db +import fpdb_import +import FpdbSQLQueries + +import unittest + +class TestSequenceFunctions(unittest.TestCase): + + def setUp(self): + """Configure MySQL settings/database and establish connection""" + self.mysql_settings={ 'db-host':"localhost", + 'db-backend':2, + 'db-databaseName':"fpdbtest", + 'db-user':"fpdb", + 'db-password':"fpdb"} + self.mysql_db = fpdb_db.fpdb_db() + self.mysql_db.connect(self.mysql_settings['db-backend'], self.mysql_settings['db-host'], + self.mysql_settings['db-databaseName'], self.mysql_settings['db-user'], + self.mysql_settings['db-password']) + self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB') + self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings) + +# """Configure Postgres settings/database and establish connection""" +# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"} +# self.pg_db = fpdb_db.fpdb_db() +# self.pg_db.connect(self.pg_settings['db-backend'], self.pg_settings['db-host'], +# self.pg_settings['db-databaseName'], self.pg_settings['db-user'], +# self.pg_settings['db-password']) +# self.pgdict = FpdbSQLQueries.FpdbSQLQueries('PostgreSQL') + + + def testDatabaseConnection(self): + """Test all supported DBs""" + self.result = self.mysql_db.cursor.execute(self.mysqldict.query['list_tables']) + self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result)) + +# self.result = self.pg_db.cursor.execute(self.pgdict.query['list_tables']) +# self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result)) + + def testMySQLRecreateTables(self): + """Test droping then recreating fpdb table schema""" + self.mysql_db.recreate_tables() + self.result = self.mysql_db.cursor.execute("SHOW TABLES") + self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result)) + + def testImportHandHistoryFiles(self): + """Test import of single HH file""" + self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt") + self.mysqlimporter.runImport() + self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories") + self.mysqlimporter.runImport() + +# def testPostgresSQLRecreateTables(self): +# """Test droping then recreating fpdb table schema""" +# self.pg_db.recreate_tables() +# self.result = self.pg_db.cursor.execute(self.pgdict.query['list_tables']) +# self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result)) + +if __name__ == '__main__': + unittest.main() + diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py new file mode 100644 index 00000000..9bc125f6 --- /dev/null +++ b/pyfpdb/SQL.py @@ -0,0 +1,298 @@ +#!/usr/bin/env python +"""SQL.py + +Set up all of the SQL statements for a given game and database type. +""" +# Copyright 2008, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# Standard Library modules + +# pyGTK modules + +# FreePokerTools modules + +class Sql: + + def __init__(self, game = 'holdem', type = 'PT3'): + self.query = {} + +############################################################################ +# +# Support for the ptracks database, a cut down PT2 stud database. +# You can safely ignore this unless you are me. +# + if game == 'razz' and type == 'ptracks': + + self.query['get_table_name'] = "select table_name from game where game_id = %s" + + self.query['get_last_hand'] = "select max(game_id) from game" + + self.query['get_recent_hands'] = "select game_id from game where game_id > %(last_hand)d" + + self.query['get_xml'] = "select xml from hand_history where game_id = %s" + + self.query['get_player_id'] = """ + select player_id from players + where screen_name = %(player)s + """ + + self.query['get_hand_info'] = """ + SELECT + game_id, + CONCAT(hole_card_1, hole_card_2, hole_card_3, hole_card_4, hole_card_5, hole_card_6, hole_card_7) AS hand, + total_won-total_bet AS net + FROM game_players + WHERE game_id = %s AND player_id = 3 + """ + + self.query['get_cards'] = """ + select + seat_number, + screen_name, + hole_card_1, + hole_card_2, + hole_card_3, + hole_card_4, + hole_card_5, + hole_card_6, + hole_card_7 + from game_players, players + where game_id = %s and game_players.player_id = players.player_id + order by seat_number + """ + + self.query['get_stats_from_hand'] = """ + SELECT player_id, + count(*) AS n, + sum(pre_fourth_raise_n) AS pfr, + sum(fourth_raise_n) AS raise_n_2, + sum(fourth_ck_raise_n) AS cr_n_2, + sum(fifth_bet_raise_n) AS br_n_3, + sum(fifth_bet_ck_raise_n) AS cr_n_3, + sum(sixth_bet_raise_n) AS br_n_4, + sum(sixth_bet_ck_raise_n) AS cr_n_4, + sum(river_bet_raise_n) AS br_n_5, + sum(river_bet_ck_raise_n) AS cr_n_5, + sum(went_to_showdown_n) AS sd, + sum(saw_fourth_n) AS saw_f, + sum(raised_first_pf) AS first_pfr, + sum(vol_put_money_in_pot) AS vpip, + sum(limp_with_prev_callers) AS limp_w_callers, + + sum(ppossible_actions) AS poss_a_pf, + sum(pfold) AS fold_pf, + sum(pcheck) AS check_pf, + sum(praise) AS raise_pf, + sum(pcall) AS raise_pf, + sum(limp_call_reraise_pf) AS limp_call_pf, + + sum(pfr_check) AS check_after_raise, + sum(pfr_call) AS call_after_raise, + sum(pfr_fold) AS fold_after_raise, + sum(pfr_bet) AS bet_after_raise, + sum(pfr_raise) AS raise_after_raise, + sum(folded_to_river_bet) AS fold_to_r_bet, + + sum(fpossible_actions) AS poss_a_2, + sum(ffold) AS fold_2, + sum(fcheck) AS check_2, + sum(fbet) AS bet_2, + sum(fraise) AS raise_2, + sum(fcall) AS raise_2, + + sum(fifpossible_actions) AS poss_a_3, + sum(fiffold) AS fold_3, + sum(fifcheck) AS check_3, + sum(fifbet) AS bet_3, + sum(fifraise) AS raise_3, + sum(fifcall) AS call_3, + + sum(spossible_actions) AS poss_a_4, + sum(sfold) AS fold_4, + sum(scheck) AS check_4, + sum(sbet) AS bet_4, + sum(sraise) AS raise_4, + sum(scall) AS call_4, + + sum(rpossible_actions) AS poss_a_5, + sum(rfold) AS fold_5, + sum(rcheck) AS check_5, + sum(rbet) AS bet_5, + sum(rraise) AS raise_5, + sum(rcall) AS call_5, + + sum(cold_call_pf) AS cc_pf, + sum(saw_fifth_n) AS saw_3, + sum(saw_sixth_n) AS saw_4, + sum(saw_river_n) AS saw_5 + FROM game_players + WHERE player_id in + (SELECT player_id FROM game_players + WHERE game_id = %s AND NOT player_id = %s) + GROUP BY player_id + """ +# alternate form of WHERE for above +# WHERE game_id = %(hand)d AND NOT player_id = %(hero)d) +# WHERE game_id = %s AND NOT player_id = %s) + + self.query['get_players_from_hand'] = """ + SELECT game_players.player_id, seat_number, screen_name + FROM game_players INNER JOIN players ON (game_players.player_id = players.player_id) + WHERE game_id = %s + """ + +###############################################################################3 +# Support for the Free Poker DataBase = fpdb http://fpdb.sourceforge.net/ +# + if type == 'fpdb': + + self.query['get_last_hand'] = "select max(id) from Hands" + + self.query['get_player_id'] = """ + select Players.id AS player_id from Players, Sites + where Players.name = %(player)s + and Sites.name = %(site)s + and Players.SiteId = Sites.id + """ + + self.query['get_stats_from_hand'] = """ + SELECT HudCache.playerId AS player_id, + sum(HDs) AS n, + sum(street0VPI) AS vpip, + sum(street0Aggr) AS pfr, + sum(street0_3B4BChance) AS TB_opp_0, + sum(street0_3B4BDone) AS TB_0, + sum(street1Seen) AS saw_f, + sum(street1Seen) AS saw_1, + sum(street2Seen) AS saw_2, + sum(street3Seen) AS saw_3, + sum(street4Seen) AS saw_4, + sum(sawShowdown) AS sd, + sum(street1Aggr) AS aggr_1, + sum(street2Aggr) AS aggr_2, + sum(street3Aggr) AS aggr_3, + sum(street4Aggr) AS aggr_4, + sum(otherRaisedStreet1) AS was_raised_1, + sum(otherRaisedStreet2) AS was_raised_2, + sum(otherRaisedStreet3) AS was_raised_3, + sum(otherRaisedStreet4) AS was_raised_4, + sum(foldToOtherRaisedStreet1) AS f_freq_1, + sum(foldToOtherRaisedStreet2) AS f_freq_2, + sum(foldToOtherRaisedStreet3) AS f_freq_3, + sum(foldToOtherRaisedStreet4) AS f_freq_4, + sum(wonWhenSeenStreet1) AS w_w_s_1, + sum(wonAtSD) AS wmsd, + sum(stealAttemptChance) AS steal_opp, + sum(stealAttempted) AS steal, + sum(foldSbToStealChance) AS SBstolen, + sum(foldedSbToSteal) AS SBnotDef, + sum(foldBbToStealChance) AS BBstolen, + sum(foldedBbToSteal) AS BBnotDef, + sum(street1CBChance) AS CB_opp_1, + sum(street1CBDone) AS CB_1, + sum(street2CBChance) AS CB_opp_2, + sum(street2CBDone) AS CB_2, + sum(street3CBChance) AS CB_opp_3, + sum(street3CBDone) AS CB_3, + sum(street4CBChance) AS CB_opp_4, + sum(street4CBDone) AS CB_4, + sum(foldToStreet1CBChance) AS f_cb_opp_1, + sum(foldToStreet1CBDone) AS f_cb_1, + sum(foldToStreet2CBChance) AS f_cb_opp_2, + sum(foldToStreet2CBDone) AS f_cb_2, + sum(foldToStreet3CBChance) AS f_cb_opp_3, + sum(foldToStreet3CBDone) AS f_cb_3, + sum(foldToStreet4CBChance) AS f_cb_opp_4, + sum(foldToStreet4CBDone) AS f_cb_4, + sum(totalProfit) AS net, + sum(street1CheckCallRaiseChance) AS ccr_opp_1, + sum(street1CheckCallRaiseDone) AS ccr_1, + sum(street2CheckCallRaiseChance) AS ccr_opp_2, + sum(street2CheckCallRaiseDone) AS ccr_2, + sum(street3CheckCallRaiseChance) AS ccr_opp_3, + sum(street3CheckCallRaiseDone) AS ccr_3, + sum(street4CheckCallRaiseChance) AS ccr_opp_4, + sum(street4CheckCallRaiseDone) AS ccr_4 + FROM HudCache, Hands + WHERE HudCache.PlayerId in + (SELECT PlayerId FROM HandsPlayers + WHERE handId = %s) + AND Hands.id = %s + AND Hands.gametypeId = HudCache.gametypeId + GROUP BY HudCache.PlayerId + """ +# AND PlayerId LIKE %s +# HudCache.gametypeId AS gametypeId, +# activeSeats AS n_active, +# position AS position, +# HudCache.tourneyTypeId AS tourneyTypeId, + + self.query['get_players_from_hand'] = """ + SELECT HandsPlayers.playerId, seatNo, name + FROM HandsPlayers INNER JOIN Players ON (HandsPlayers.playerId = Players.id) + WHERE handId = %s + """ +# WHERE handId = %s AND Players.id LIKE %s + + self.query['get_table_name'] = """ + select tableName, maxSeats, category + from Hands,Gametypes + where Hands.id = %s + and Gametypes.id = Hands.gametypeId + """ + + self.query['get_actual_seat'] = """ + select seatNo + from HandsPlayers + where HandsPlayers.handId = %s + and HandsPlayers.playerId = (select Players.id from Players + where Players.name = %s) + """ + + self.query['get_cards'] = """ + select + seatNo AS seat_number, + name AS screen_name, + card1Value, card1Suit, + card2Value, card2Suit, + card3Value, card3Suit, + card4Value, card4Suit, + card5Value, card5Suit, + card6Value, card6Suit, + card7Value, card7Suit + from HandsPlayers, Players + where handID = %s and HandsPlayers.playerId = Players.id + order by seatNo + """ + +# self.query['get_hand_info'] = """ +# SELECT +# game_id, +# CONCAT(hole_card_1, hole_card_2, hole_card_3, hole_card_4, hole_card_5, hole_card_6, hole_card_7) AS hand, +# total_won-total_bet AS net +# FROM game_players +# WHERE game_id = %s AND player_id = 3 +# """ + +if __name__== "__main__": +# just print the default queries and exit + s = Sql(game = 'razz', type = 'ptracks') + for key in s.query: + print "For query " + key + ", sql =" + print s.query[key] diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py new file mode 100644 index 00000000..7bb9a8c5 --- /dev/null +++ b/pyfpdb/Stats.py @@ -0,0 +1,628 @@ +#!/usr/bin/env python + +"""Manage collecting and formatting of stats and tooltips. +""" +# Copyright 2008, Ray E. Barker + +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# How to write a new stat: +# 1 You can see a listing of all the raw stats (e.g., from the HudCache table) +# by running Database.py as a stand along program. You need to combine +# those raw stats to get stats to present to the HUD. If you need more +# information than is in the HudCache table, then you have to write SQL. +# 2 The raw stats seen when you run Database.py are available in the Stats.py +# in the stat_dict dict. For example the number of vpips would be +# stat_dict[player]['vpip']. So the % vpip is +# float(stat_dict[player]['vpip'])/float(stat_dict[player]['n']). You can see how the +# keys of stat_dict relate to the column names in HudCache by inspecting +# the proper section of the SQL.py module. +# 3 You have to write a small function for each stat you want to add. See +# the vpip() function for example. This function has to be protected from +# exceptions, using something like the try:/except: paragraphs in vpip. +# 4 The name of the function has to be the same as the of the stat used +# in the config file. +# 5 The stat functions have a peculiar return value, which is outlined in +# the do_stat function. This format is useful for tool tips and maybe +# other stuff. +# 6 For each stat you make add a line to the __main__ function to test it. + +# Standard Library modules +#import sys + +# pyGTK modules +import pygtk +import gtk + +# FreePokerTools modules +import Configuration +import Database + +def do_tip(widget, tip): + widget.set_tooltip_text(tip) + +def do_stat(stat_dict, player = 24, stat = 'vpip'): + return eval("%(stat)s(stat_dict, %(player)d)" % {'stat': stat, 'player': player}) + +# OK, for reference the tuple returned by the stat is: +# 0 - The stat, raw, no formating, eg 0.33333333 +# 1 - formatted stat with appropriate precision and punctuation, eg 33% +# 2 - formatted stat with appropriate precision, punctuation and a hint, eg v=33% +# 3 - same as #2 except name of stat instead of hint, eg vpip=33% +# 4 - the calculation that got the stat, eg 9/27 +# 5 - the name of the stat, useful for a tooltip, eg vpip + +########################################### +# functions that return individual stats + +def playername(stat_dict, player): + return (stat_dict[player]['screen_name'], + stat_dict[player]['screen_name'], + stat_dict[player]['screen_name'], + stat_dict[player]['screen_name'], + stat_dict[player]['screen_name'], + stat_dict[player]['screen_name']) + +def vpip(stat_dict, player): + """ Voluntarily put $ in the pot.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['vpip'])/float(stat_dict[player]['n']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'v=%3.1f' % (100*stat) + '%', + 'vpip=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['vpip'], stat_dict[player]['n']), + 'vpip' + ) + except: return (stat, + '%3.1f' % (0) + '%', + 'w=%3.1f' % (0) + '%', + 'wtsd=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'wtsd' + ) + +def pfr(stat_dict, player): + """ Preflop (3rd street) raise.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['pfr'])/float(stat_dict[player]['n']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'p=%3.1f' % (100*stat) + '%', + 'pfr=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['pfr'], stat_dict[player]['n']), + 'pfr' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'p=%3.1f' % (0) + '%', + 'pfr=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'pfr' + ) + +def wtsd(stat_dict, player): + """ Went to SD when saw flop/4th.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['sd'])/float(stat_dict[player]['saw_f']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'w=%3.1f' % (100*stat) + '%', + 'wtsd=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['sd'], stat_dict[player]['saw_f']), + '% went to showdown' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'w=%3.1f' % (0) + '%', + 'wtsd=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% went to showdown' + ) + +def wmsd(stat_dict, player): + """ Won $ at showdown.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['wmsd'])/float(stat_dict[player]['sd']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'w=%3.1f' % (100*stat) + '%', + 'wmsd=%3.1f' % (100*stat) + '%', + '(%f5.0/%d)' % (stat_dict[player]['wmsd'], stat_dict[player]['sd']), + '% won money at showdown' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'w=%3.1f' % (0) + '%', + 'wmsd=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% won money at showdown' + ) + +def saw_f(stat_dict, player): + """ Saw flop/4th.""" + try: + num = float(stat_dict[player]['saw_f']) + den = float(stat_dict[player]['n']) + stat = num/den + return (stat, + '%3.1f' % (100*stat) + '%', + 'sf=%3.1f' % (100*stat) + '%', + 'saw_f=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['saw_f'], stat_dict[player]['n']), + 'saw_f' + ) + except: + stat = 0.0 + num = 0 + den = 0 + return (stat, + '%3.1f' % (stat) + '%', + 'sf=%3.1f' % (stat) + '%', + 'saw_f=%3.1f' % (stat) + '%', + '(%d/%d)' % (num, den), + 'saw_f' + ) + +def n(stat_dict, player): + """ Number of hands played.""" + try: + return (stat_dict[player]['n'], + '%d' % (stat_dict[player]['n']), + 'n=%d' % (stat_dict[player]['n']), + 'n=%d' % (stat_dict[player]['n']), + '(%d)' % (stat_dict[player]['n']), + 'number hands seen' + ) + except: + return (0, + '%d' % (0), + 'n=%d' % (0), + 'n=%d' % (0), + '(%d)' % (0), + 'number hands seen' + ) + +def fold_f(stat_dict, player): + """ Folded flop/4th.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['fold_2'])/fold(stat_dict[player]['saw_f']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'ff=%3.1f' % (100*stat) + '%', + 'fold_f=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['fold_2'], stat_dict[player]['saw_f']), + 'folded flop/4th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'ff=%3.1f' % (0) + '%', + 'fold_f=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'folded flop/4th' + ) + +def steal(stat_dict, player): + """ Steal %.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['steal'])/float(stat_dict[player]['steal_opp']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'st=%3.1f' % (100*stat) + '%', + 'steal=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['steal'], stat_dict[player]['steal_opp']), + '% steal attempted' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'st=%3.1f' % (0) + '%', + 'steal=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% steal attempted' + ) + +def f_SB_steal(stat_dict, player): + """ Folded SB to steal.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['SBnotDef'])/float(stat_dict[player]['SBstolen']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'fSB=%3.1f' % (100*stat) + '%', + 'fSB_s=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['SBnotDef'], stat_dict[player]['SBstolen']), + '% folded SB to steal' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'fSB=%3.1f' % (0) + '%', + 'fSB_s=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% folded SB to steal' + ) + +def f_BB_steal(stat_dict, player): + """ Folded BB to steal.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['BBnotDef'])/float(stat_dict[player]['BBstolen']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'fBB=%3.1f' % (100*stat) + '%', + 'fBB_s=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['BBnotDef'], stat_dict[player]['BBstolen']), + '% folded BB to steal' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'fBB=%3.1f' % (0) + '%', + 'fBB_s=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% folded BB to steal' + ) + +def three_B_0(stat_dict, player): + """ Three bet preflop/3rd.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['TB_0'])/float(stat_dict[player]['TB_opp_0']) + return (stat, + '%3.1f' % (100*stat) + '%', + '3B=%3.1f' % (100*stat) + '%', + '3B_pf=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['TB_0'], stat_dict[player]['TB_opp_0']), + '% 3/4 Bet preflop/3rd' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + '3B=%3.1f' % (0) + '%', + '3B_pf=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% 3/4 Bet preflop/3rd' + ) + +def WMsF(stat_dict, player): + """ Won $ when saw flop/4th.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['w_w_s_1'])/float(stat_dict[player]['saw_1']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'wf=%3.1f' % (100*stat) + '%', + 'w_w_f=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['w_w_s_1'], stat_dict[player]['saw_f']), + '% won$/saw flop/4th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'wf=%3.1f' % (0) + '%', + 'w_w_f=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% won$/saw flop/4th' + ) + +def a_freq_1(stat_dict, player): + """ Flop/4th aggression frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['aggr_1'])/float(stat_dict[player]['saw_f']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'a1=%3.1f' % (100*stat) + '%', + 'a_fq_1=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['aggr_1'], stat_dict[player]['saw_f']), + 'Aggression Freq flop/4th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'a1=%3.1f' % (0) + '%', + 'a_fq_1=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'Aggression Freq flop/4th' + ) + +def a_freq_2(stat_dict, player): + """ Turn/5th aggression frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['aggr_2'])/float(stat_dict[player]['saw_2']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'a2=%3.1f' % (100*stat) + '%', + 'a_fq_2=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['aggr_2'], stat_dict[player]['saw_2']), + 'Aggression Freq turn/5th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'a2=%3.1f' % (0) + '%', + 'a_fq_2=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'Aggression Freq turn/5th' + ) + +def a_freq_3(stat_dict, player): + """ River/6th aggression frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['aggr_3'])/float(stat_dict[player]['saw_3']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'a3=%3.1f' % (100*stat) + '%', + 'a_fq_3=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['aggr_3'], stat_dict[player]['saw_3']), + 'Aggression Freq river/6th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'a3=%3.1f' % (0) + '%', + 'a_fq_3=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'Aggression Freq river/6th' + ) + +def a_freq_4(stat_dict, player): + """ 7th street aggression frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['aggr_4'])/float(stat_dict[player]['saw_4']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'a4=%3.1f' % (100*stat) + '%', + 'a_fq_4=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['aggr_4'], stat_dict[player]['saw_4']), + 'Aggression Freq 7th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'a4=%3.1f' % (0) + '%', + 'a_fq_4=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + 'Aggression Freq flop/4th' + ) + +def cb_1(stat_dict, player): + """ Flop continuation bet.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['CB_1'])/float(stat_dict[player]['CB_opp_1']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'cb1=%3.1f' % (100*stat) + '%', + 'cb_1=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['CB_1'], stat_dict[player]['CB_opp_1']), + '% continuation bet flop/4th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'cb1=%3.1f' % (0) + '%', + 'cb_1=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% continuation bet flop/4th' + ) + +def cb_2(stat_dict, player): + """ Turn continuation bet.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['CB_2'])/float(stat_dict[player]['CB_opp_2']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'cb2=%3.1f' % (100*stat) + '%', + 'cb_2=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['CB_2'], stat_dict[player]['CB_opp_2']), + '% continuation bet turn/5th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'cb2=%3.1f' % (0) + '%', + 'cb_2=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% continuation bet turn/5th' + ) + +def cb_3(stat_dict, player): + """ River continuation bet.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['CB_3'])/float(stat_dict[player]['CB_opp_3']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'cb3=%3.1f' % (100*stat) + '%', + 'cb_3=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['CB_3'], stat_dict[player]['CB_opp_3']), + '% continuation bet river/6th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'cb3=%3.1f' % (0) + '%', + 'cb_3=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% continuation bet river/6th' + ) + +def cb_4(stat_dict, player): + """ 7th street continuation bet.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['CB_4'])/float(stat_dict[player]['CB_opp_4']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'cb4=%3.1f' % (100*stat) + '%', + 'cb_4=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['CB_4'], stat_dict[player]['CB_opp_4']), + '% continuation bet 7th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'cb4=%3.1f' % (0) + '%', + 'cb_4=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% continuation bet 7th' + ) + +def ffreq_1(stat_dict, player): + """ Flop/4th fold frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['f_freq_1'])/float(stat_dict[player]['was_raised_1']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'ff1=%3.1f' % (100*stat) + '%', + 'ff_1=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['f_freq_1'], stat_dict[player]['was_raised_1']), + '% fold frequency flop/4th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'ff1=%3.1f' % (0) + '%', + 'ff_1=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% fold frequency flop/4th' + ) + +def ffreq_2(stat_dict, player): + """ Turn/5th fold frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['f_freq_2'])/float(stat_dict[player]['was_raised_2']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'ff2=%3.1f' % (100*stat) + '%', + 'ff_2=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['f_freq_2'], stat_dict[player]['was_raised_2']), + '% fold frequency turn/5th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'ff2=%3.1f' % (0) + '%', + 'ff_2=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% fold frequency turn/5th' + ) + +def ffreq_3(stat_dict, player): + """ River/6th fold frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['f_freq_3'])/float(stat_dict[player]['was_raised_3']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'ff3=%3.1f' % (100*stat) + '%', + 'ff_3=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['f_freq_3'], stat_dict[player]['was_raised_3']), + '% fold frequency river/6th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'ff3=%3.1f' % (0) + '%', + 'ff_3=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% fold frequency river/6th' + ) + +def ffreq_4(stat_dict, player): + """ 7th fold frequency.""" + stat = 0.0 + try: + stat = float(stat_dict[player]['f_freq_4'])/float(stat_dict[player]['was_raised_4']) + return (stat, + '%3.1f' % (100*stat) + '%', + 'ff4=%3.1f' % (100*stat) + '%', + 'ff_4=%3.1f' % (100*stat) + '%', + '(%d/%d)' % (stat_dict[player]['f_freq_4'], stat_dict[player]['was_raised_4']), + '% fold frequency 7th' + ) + except: + return (stat, + '%3.1f' % (0) + '%', + 'ff4=%3.1f' % (0) + '%', + 'ff_4=%3.1f' % (0) + '%', + '(%d/%d)' % (0, 0), + '% fold frequency 7th' + ) + +if __name__== "__main__": + c = Configuration.Config() + db_connection = Database.Database(c, 'fpdb', 'holdem') + h = db_connection.get_last_hand() + stat_dict = db_connection.get_stats_from_hand(h) + + for player in stat_dict.keys(): + print "player = ", player, do_stat(stat_dict, player = player, stat = 'vpip') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'pfr') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'wtsd') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'saw_f') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'n') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'fold_f') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'wmsd') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'steal') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_SB_steal') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_BB_steal') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'three_B_0') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'WMsF') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_1') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_2') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_3') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_4') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb_1') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb_2') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb_3') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb_4') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq_1') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq_2') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq_3') + print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq_4') + + print "\n\nLegal stats:" + for attr in dir(): + if attr.startswith('__'): continue + if attr in ("Configuration", "Database", "GInitiallyUnowned", "gtk", "pygtk", + "player", "c", "db_connection", "do_stat", "do_tip", "stat_dict", + "h"): continue + print attr, eval("%s.__doc__" % (attr)) +# print " " % (attr) + + db_connection.close + diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py new file mode 100644 index 00000000..752c5929 --- /dev/null +++ b/pyfpdb/Tables.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +"""Discover_Tables.py + +Inspects the currently open windows and finds those of interest to us--that is +poker table windows from supported sites. Returns a list +of Table_Window objects representing the windows found. +""" +# Copyright 2008, Ray E. Barker + +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +# Standard Library modules +import os +import sys +import re + +# Win32 modules + +if os.name == 'nt': + import win32gui + import win32process + import win32api + import win32con + +# FreePokerTools modules +import Configuration + +class Table_Window: + def __str__(self): +# __str__ method for testing + temp = 'TableWindow object\n' + temp = temp + " name = %s\n site = %s\n number = %s\n title = %s\n" % (self.name, self.site, self.number, self.title) +# temp = temp + " game = %s\n structure = %s\n max = %s\n" % (self.game, self.structure, self.max) + temp = temp + " width = %d\n height = %d\n x = %d\n y = %d\n" % (self.width, self.height, self.x, self.y) + if getattr(self, 'tournament', 0): + temp = temp + " tournament = %d\n table = %d" % (self.tournament, self.table) + return temp + + def get_details(table): + table.game = 'razz' + table.max = 8 + table.struture = 'limit' + table.tournament = 0 + +def discover(c): + if os.name == 'posix': + tables = discover_posix(c) + elif os.name == 'nt': + tables = discover_nt(c) + elif os.name == 'mac': + tables = discover_mac(c) + else: + tables = {} + + return(tables) + +def discover_table_by_name(c, tablename): + if os.name == 'posix': + table = discover_posix_by_name(c, tablename) + elif os.name == 'nt': + table = discover_nt_by_name(c, tablename) + elif os.name == 'mac': + table = discover_mac_by_name(c, tablename) + else: + table = None + return(table) + +def discover_posix(c): + """ Poker client table window finder for posix/Linux = XWindows.""" + tables = {} + for listing in os.popen('xwininfo -root -tree').readlines(): +# xwininfo -root -tree -id 0xnnnnn gets the info on a single window + if re.search('Lobby', listing): continue + if re.search('Instant Hand History', listing): continue + if not re.search('Logged In as ', listing, re.IGNORECASE): continue + if re.search('\"Full Tilt Poker\"', listing): continue # FTP Lobby + for s in c.supported_sites.keys(): + if re.search(c.supported_sites[s].table_finder, listing): + mo = re.match('\s+([\dxabcdef]+) (.+):.+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing) + if mo.group(2) == '(has no name)': continue + if re.match('[\(\)\d\s]+', mo.group(2)): continue # this is a popup + tw = Table_Window() + tw.site = c.supported_sites[s].site_name + tw.number = int(mo.group(1), 0) + tw.title = mo.group(2) + tw.width = int( mo.group(3) ) + tw.height = int( mo.group(4) ) + tw.x = int (mo.group(5) ) + tw.y = int (mo.group(6) ) + tw.title = re.sub('\"', '', tw.title) + +# use this eval thingie to call the title bar decoder specified in the config file + eval("%s(tw)" % c.supported_sites[s].decoder) + + tables[tw.name] = tw + return tables + +def discover_posix_by_name(c, tablename): + tables = discover_posix(c) + for t in tables: + if tables[t].name.find(tablename) > -1: + return tables[t] + return None + +# +# The discover_xx functions query the system and report on the poker clients +# currently displayed on the screen. The discover_posix should give you +# some idea how to support other systems. +# +# discover_xx() returns a dict of TableWindow objects--one TableWindow +# object for each poker client table on the screen. +# +# Each TableWindow object must have the following attributes correctly populated: +# tw.site = the site name, e.g. PokerStars, FullTilt. This must match the site +# name specified in the config file. +# tw.number = This is the system id number for the client table window in the +# format that the system presents it. +# tw.title = The full title from the window title bar. +# tw.width, tw.height = The width and height of the window in pixels. This is +# the internal width and height, not including the title bar and +# window borders. +# tw.x, tw.y = The x, y (horizontal, vertical) location of the window relative +# to the top left of the display screen. This also does not include the +# title bar and window borders. To put it another way, this is the +# screen location of (0, 0) in the working window. + +def win_enum_handler(hwnd, titles): + titles[hwnd] = win32gui.GetWindowText(hwnd) + + +def child_enum_handler(hwnd, children): + print hwnd, win32.GetWindowRect(hwnd) + +def discover_nt(c): + """ Poker client table window finder for Windows.""" +# +# I cannot figure out how to get the inside dimensions of the poker table +# windows. So I just assume all borders are 3 thick and all title bars +# are 29 high. No doubt this will be off when used with certain themes. +# + b_width = 3 + tb_height = 29 + titles = {} + tables = {} + win32gui.EnumWindows(win_enum_handler, titles) + for hwnd in titles.keys(): + if re.search('Logged In as', titles[hwnd], re.IGNORECASE) and not re.search('Lobby', titles[hwnd]): + if re.search('Full Tilt Poker', titles[hwnd]): + continue + tw = Table_Window() + tw.number = hwnd + (x, y, width, height) = win32gui.GetWindowRect(hwnd) + tw.title = titles[hwnd] + tw.width = int( width ) - 2*b_width + tw.height = int( height ) - b_width - tb_height + tw.x = int( x ) + b_width + tw.y = int( y ) + tb_height + if re.search('Logged In as', titles[hwnd]): + tw.site = "PokerStars" + elif re.search('Logged In As', titles[hwnd]): #wait, what??! + tw.site = "Full Tilt" + else: + tw.site = "Unknown" + sys.stderr.write("Found unknown table = %s" % tw.title) + if not tw.site == "Unknown": + eval("%s(tw)" % c.supported_sites[tw.site].decoder) + else: + tw.name = "Unknown" + tables[len(tables)] = tw + return tables + +def discover_nt_by_name(c, tablename): + # this is pretty much identical to the 'search all windows for all poker sites' code, but made to dig just for a specific table name + # it could be implemented a bunch better - and we need to not assume the width/height thing that (steffen?) assumed above, we should + # be able to dig up the window's titlebar handle and get it's information, and such .. but.. for now, i guess this will work. + # - eric + b_width = 3 + tb_height = 29 + titles = {} +# tables = discover_nt(c) + win32gui.EnumWindows(win_enum_handler, titles) + for s in c.supported_sites.keys(): + for hwnd in titles.keys(): + processid = win32process.GetWindowThreadProcessId(hwnd) + pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1]) + exe = win32process.GetModuleFileNameEx(pshandle, 0) + if exe.find(c.supported_sites[s].table_finder) == -1: + continue + if titles[hwnd].find(tablename) > -1: + if titles[hwnd].find("History for table:") > -1 or titles[hwnd].find("FPDBHUD") > -1: + continue + tw = Table_Window() + tw.number = hwnd + (x, y, width, height) = win32gui.GetWindowRect(hwnd) + tw.title = titles[hwnd] + tw.width = int(width) - 2 * b_width + tw.height = int(height) - b_width - tb_height + tw.x = int(x) + b_width + tw.y = int(y) + tb_height + tw.site = c.supported_sites[s].site_name + if not tw.site == "Unknown" and not c.supported_sites[tw.site].decoder == "Unknown": + eval("%s(tw)" % c.supported_sites[tw.site].decoder) + else: + tw.name = tablename + return tw + + # if we don't find anything by process name, let's search one more time, and call it Unknown ? + for hwnd in titles.keys(): + if titles[hwnd].find(tablename) > -1: + if titles[hwnd].find("History for table:") > -1 or titles[hwnd].find("FPDBHUD") > -1: + continue + tw = Table_Window() + tw.number = hwnd + (x, y, width, height) = win32gui.GetWindowRect(hwnd) + tw.title = titles[hwnd] + tw.width = int(width) - 2 * b_width + tw.height = int(height) - b_width - tb_height + tw.x = int(x) + b_width + tw.y = int(y) + tb_height + tw.site = "Unknown" + tw.name = tablename + return tw + + return None + +def discover_mac(c): + """ Poker client table window finder for Macintosh.""" + tables = {} + return tables + +def discover_mac_by_name(c, tablename): + # again, i have no mac to test this on, sorry -eric + return discover_mac(c) + + +def pokerstars_decode_table(tw): +# extract the table name OR the tournament number and table name from the title +# other info in title is redundant with data in the database + title_bits = re.split(' - ', tw.title) + name = title_bits[0] + mo = re.search('Tournament (\d+) Table (\d+)', name) + if mo: + tw.tournament = int( mo.group(1) ) + tw.table = int( mo.group(2) ) + tw.name = name + else: + tw.tournament = None + for pattern in [' no all-in', ' fast', ',', ' 50BB min']: + name = re.sub(pattern, '', name) + name = re.sub('\s+$', '', name) + tw.name = name + + mo = re.search('(Razz|Stud H/L|Stud|Omaha H/L|Omaha|Hold\'em|5-Card Draw|Triple Draw 2-7 Lowball)', tw.title) + + tw.game = mo.group(1).lower() + tw.game = re.sub('\'', '', tw.game) + tw.game = re.sub('h/l', 'hi/lo', tw.game) + + mo = re.search('(No Limit|Pot Limit)', tw.title) + if mo: + tw.structure = mo.group(1).lower() + else: + tw.structure = 'limit' + + tw.max = None + if tw.game in ('razz', 'stud', 'stud hi/lo'): + tw.max = 8 + elif tw.game in ('5-card draw', 'triple draw 2-7 lowball'): + tw.max = 6 + elif tw.game == 'holdem': + pass + elif tw.game in ('omaha', 'omaha hi/lo'): + pass + +def fulltilt_decode_table(tw): +# extract the table name OR the tournament number and table name from the title +# other info in title is redundant with data in the database + title_bits = re.split(' - ', tw.title) + name = title_bits[0] + tw.tournament = None + for pattern in [' (6 max)', ' (heads up)', ' (deep)', + ' (deep hu)', ' (deep 6)', ' (2)', + ' (edu)', ' (edu, 6 max)', ' (6)' ]: + name = re.sub(pattern, '', name) +# (tw.name, trash) = name.split(r' (', 1) + tw.name = name.rstrip() + +if __name__=="__main__": + c = Configuration.Config() + print discover_table_by_name(c, "Catacaos") + tables = discover(c) + + for t in tables.keys(): + print "t = ", t + print tables[t] + + print "press enter to continue" + sys.stdin.readline() diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py new file mode 100755 index 00000000..bec9be78 --- /dev/null +++ b/pyfpdb/fpdb.py @@ -0,0 +1,449 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import os +import sys +from optparse import OptionParser + + +parser = OptionParser() +parser.add_option("-x", "--errorsToConsole", action="store_true", + help="If passed error output will go to the console rather than .") +(options, sys.argv) = parser.parse_args() + +if not options.errorsToConsole: + print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_." + errorFile = open('fpdb-error-log.txt', 'w', 0) + sys.stderr = errorFile + +import pygtk +pygtk.require('2.0') +import gtk + +import fpdb_db +import fpdb_simple +import GuiBulkImport +import GuiTableViewer +import GuiAutoImport +import GuiGraphViewer +import FpdbSQLQueries +import Configuration + +class fpdb: + def tab_clicked(self, widget, tab_name): + """called when a tab button is clicked to activate that tab""" + #print "start of tab_clicked" + self.display_tab(tab_name) + #end def tab_clicked + + def add_and_display_tab(self, new_tab, new_tab_name): + """just calls the component methods""" + self.add_tab(new_tab, new_tab_name) + self.display_tab(new_tab_name) + #end def add_and_display_tab + + def add_tab(self, new_tab, new_tab_name): + """adds a tab, namely creates the button and displays it and appends all the relevant arrays""" + #print "start of add_tab" + for i in self.tab_names: #todo: check this is valid + if i==new_tab_name: + raise fpdb_simple.FpdbError("duplicate tab_name not permitted") + + self.tabs.append(new_tab) + self.tab_names.append(new_tab_name) + + new_tab_sel_button=gtk.ToggleButton(new_tab_name) + new_tab_sel_button.connect("clicked", self.tab_clicked, new_tab_name) + self.tab_box.add(new_tab_sel_button) + new_tab_sel_button.show() + self.tab_buttons.append(new_tab_sel_button) + #end def add_tab + + def display_tab(self, new_tab_name): + """displays the indicated tab""" + #print "start of display_tab, len(self.tab_names):",len(self.tab_names) + tab_no=-1 + #if len(self.tab_names)>1: + for i in range(len(self.tab_names)): + #print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i] + if (new_tab_name==self.tab_names[i]): + tab_no=i + #self.tab_buttons[i].set_active(False) + #else: + # tab_no=0 + + #current_tab_no=-1 + for i in range(len(self.tab_names)): + if self.current_tab==self.tabs[i]: + #self.tab_buttons[i].set_active(False) + pass + + if tab_no==-1: + raise fpdb_simple.FpdbError("invalid tab_no") + else: + self.main_vbox.remove(self.current_tab) + #self.current_tab.destroy() + self.current_tab=self.tabs[tab_no] + self.main_vbox.add(self.current_tab) + self.tab_buttons[tab_no].set_active(True) + self.current_tab.show() + #end def display_tab + + def delete_event(self, widget, event, data=None): + return False + #end def delete_event + + def destroy(self, widget, data=None): + self.quit(widget, data) + #end def destroy + + def dia_about(self, widget, data): + print "todo: implement dia_about" + #end def dia_about + + def dia_create_del_database(self, widget, data): + print "todo: implement dia_create_del_database" + obtain_global_lock() + #end def dia_create_del_database + + def dia_create_del_user(self, widget, data): + print "todo: implement dia_create_del_user" + obtain_global_lock() + #end def dia_create_del_user + + def dia_database_stats(self, widget, data): + print "todo: implement dia_database_stats" + #string=fpdb_db.getDbStats(db, cursor) + #end def dia_database_stats + + def dia_delete_db_parts(self, widget, data): + print "todo: implement dia_delete_db_parts" + obtain_global_lock() + #end def dia_delete_db_parts + + def dia_edit_profile(self, widget=None, data=None, create_default=False, path=None): + print "todo: implement dia_edit_profile" + obtain_global_lock() + #end def dia_edit_profile + + def dia_export_db(self, widget, data): + print "todo: implement dia_export_db" + obtain_global_lock() + #end def dia_export_db + + def dia_get_db_root_credentials(self): + """obtains db root credentials from user""" + print "todo: implement dia_get_db_root_credentials" +# user, pw=None, None +# +# dialog=gtk.Dialog(title="DB Credentials needed", parent=None, flags=0, +# buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,"Connect and recreate",gtk.RESPONSE_OK)) +# +# label_warning1=gtk.Label("Please enter credentials for a database user for "+self.host+" that has permissions to create a database.") +# +# +# label_user=gtk.Label("Username") +# dialog.vbox.add(label_user) +# label_user.show() +# +# response=dialog.run() +# dialog.destroy() +# return (user, pw, response) + #end def dia_get_db_root_credentials + + def dia_import_db(self, widget, data): + print "todo: implement dia_import_db" + obtain_global_lock() + #end def dia_import_db + + def dia_licensing(self, widget, data): + print "todo: implement dia_licensing" + #end def dia_licensing + + def dia_load_profile(self, widget, data): + """Dialogue to select a file to load a profile from""" + self.obtain_global_lock() + chooser = gtk.FileChooserDialog(title="Please select a profile file to load", + action=gtk.FILE_CHOOSER_ACTION_OPEN, + buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + chooser.set_filename(self.profile) + + response = chooser.run() + chooser.destroy() + if response == gtk.RESPONSE_OK: + self.load_profile(chooser.get_filename()) + elif response == gtk.RESPONSE_CANCEL: + print 'User cancelled loading profile' + #end def dia_load_profile + + def dia_recreate_tables(self, widget, data): + """Dialogue that asks user to confirm that he wants to delete and recreate the tables""" + self.obtain_global_lock() + dia_confirm=gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, + buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables") + diastring=("Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted.") + dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted + + response=dia_confirm.run() + dia_confirm.destroy() + if response == gtk.RESPONSE_YES: + self.db.recreate_tables() + elif response == gtk.RESPONSE_NO: + print 'User cancelled recreating tables' + #end def dia_recreate_tables + + def dia_regression_test(self, widget, data): + print "todo: implement dia_regression_test" + self.obtain_global_lock() + #end def dia_regression_test + + def dia_save_profile(self, widget, data): + print "todo: implement dia_save_profile" + #end def dia_save_profile + + def diaSetupWizard(self, path): + print "todo: implement setup wizard" + print "setup wizard not implemented - please create the default configuration file:", path + diaSetupWizard = gtk.Dialog(title="Fatal Error - Config File Missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK)) + + label = gtk.Label("Please copy the config file from the docs folder to:") + diaSetupWizard.vbox.add(label) + label.show() + + label = gtk.Label(path) + diaSetupWizard.vbox.add(label) + label.show() + + label = gtk.Label("and edit it according to the install documentation at http://fpdb.sourceforge.net") + diaSetupWizard.vbox.add(label) + label.show() + + response = diaSetupWizard.run() + sys.exit(1) + #end def diaSetupWizard + + def get_menu(self, window): + """returns the menu for this program""" + accel_group = gtk.AccelGroup() + self.item_factory = gtk.ItemFactory(gtk.MenuBar, "
", accel_group) + self.item_factory.create_items(self.menu_items) + window.add_accel_group(accel_group) + return self.item_factory.get_widget("
") + #end def get_menu + + def load_profile(self): + """Loads profile from the provided path name.""" + self.settings = {} + if (os.sep=="/"): + self.settings['os']="linuxmac" + else: + self.settings['os']="windows" + + self.settings.update(self.config.get_db_parameters()) + self.settings.update(self.config.get_tv_parameters()) + self.settings.update(self.config.get_import_parameters()) + self.settings.update(self.config.get_default_paths()) + + if self.db!=None: + self.db.disconnect() + + self.db = fpdb_db.fpdb_db() + #print "end of fpdb.load_profile, databaseName:",self.settings['db-databaseName'] + self.db.connect(self.settings['db-backend'], self.settings['db-host'], self.settings['db-databaseName'], self.settings['db-user'], self.settings['db-password']) + if self.db.wrongDbVersion: + diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK)) + + label = gtk.Label("An invalid DB version or missing tables have been detected.") + diaDbVersionWarning.vbox.add(label) + label.show() + + label = gtk.Label("This error is not necessarily fatal but it is strongly recommended that you recreate the tables by using the Database menu.") + diaDbVersionWarning.vbox.add(label) + label.show() + + label = gtk.Label("Not doing this will likely lead to misbehaviour including fpdb crashes, corrupt data etc.") + diaDbVersionWarning.vbox.add(label) + label.show() + + response = diaDbVersionWarning.run() + diaDbVersionWarning.destroy() + + # Database connected to successfully, load queries to pass on to other classes + self.querydict = FpdbSQLQueries.FpdbSQLQueries(self.db.get_backend_name()) + #end def load_profile + + def not_implemented(self): + print "todo: called unimplemented menu entry (users: pls ignore this)"#remove this once more entries are implemented + #end def not_implemented + + def obtain_global_lock(self): + print "todo: implement obtain_global_lock (users: pls ignore this)" + #end def obtain_global_lock + + def quit(self, widget, data): + print "Quitting normally" + #check if current settings differ from profile, if so offer to save or abort + self.db.disconnect() + gtk.main_quit() + #end def quit_cliecked + + def release_global_lock(self): + print "todo: implement release_global_lock" + #end def release_global_lock + + def tab_abbreviations(self, widget, data): + print "todo: implement tab_abbreviations" + #end def tab_abbreviations + + def tab_auto_import(self, widget, data): + """opens the auto import tab""" + new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings, self.config) + self.threads.append(new_aimp_thread) + aimp_tab=new_aimp_thread.get_vbox() + self.add_and_display_tab(aimp_tab, "Auto Import") + #end def tab_auto_import + + def tab_bulk_import(self, widget, data): + """opens a tab for bulk importing""" + #print "start of tab_bulk_import" + new_import_thread=GuiBulkImport.GuiBulkImport(self.db, self.settings, self.config) + self.threads.append(new_import_thread) + bulk_tab=new_import_thread.get_vbox() + self.add_and_display_tab(bulk_tab, "Bulk Import") + #end def tab_bulk_import + + def tab_main_help(self, widget, data): + """Displays a tab with the main fpdb help screen""" + #print "start of tab_main_help" + mh_tab=gtk.Label("""Welcome to Fpdb! +For documentation please visit our website at http://fpdb.sourceforge.net/ or check the docs directory in the fpdb folder. +Please note that default.conf is no longer needed nor used, all configuration now happens in HUD_config.xml +This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") + self.add_and_display_tab(mh_tab, "Help") + #end def tab_main_help + + def tab_table_viewer(self, widget, data): + """opens a table viewer tab""" + #print "start of tab_table_viewer" + new_tv_thread=GuiTableViewer.GuiTableViewer(self.db, self.settings) + self.threads.append(new_tv_thread) + tv_tab=new_tv_thread.get_vbox() + self.add_and_display_tab(tv_tab, "Table Viewer") + #end def tab_table_viewer + + def tabGraphViewer(self, widget, data): + """opens a graph viewer tab""" + #print "start of tabGraphViewer" + new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings, self.querydict, self.config) + self.threads.append(new_gv_thread) + gv_tab=new_gv_thread.get_vbox() + self.add_and_display_tab(gv_tab, "Graphs") + #end def tabGraphViewer + + def __init__(self): + self.threads=[] + self.db=None + self.config = Configuration.Config() + self.load_profile() + + self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.window.connect("delete_event", self.delete_event) + self.window.connect("destroy", self.destroy) + self.window.set_title("Free Poker DB - version: alpha9+, p143 or higher") + self.window.set_border_width(1) + self.window.set_size_request(1020,400) + self.window.set_resizable(True) + + self.menu_items = ( + ( "/_Main", None, None, 0, "" ), + ( "/Main/_Load Profile (broken)", "L", self.dia_load_profile, 0, None ), + ( "/Main/_Edit Profile (todo)", "E", self.dia_edit_profile, 0, None ), + ( "/Main/_Save Profile (todo)", None, self.dia_save_profile, 0, None ), + ("/Main/sep1", None, None, 0, "" ), + ("/Main/_Quit", "Q", self.quit, 0, None ), + ("/_Import", None, None, 0, "" ), + ("/Import/_Bulk Import", "B", self.tab_bulk_import, 0, None ), + ("/Import/_Auto Import and HUD", "A", self.tab_auto_import, 0, None ), + ("/Import/Auto _Rating (todo)", "R", self.not_implemented, 0, None ), + ("/_Viewers", None, None, 0, "" ), + ("/_Viewers/_Auto Import and HUD", "A", self.tab_auto_import, 0, None ), + ("/Viewers/_Graphs", "G", self.tabGraphViewer, 0, None ), + ("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/Poker_table Viewer (mostly obselete)", "T", self.tab_table_viewer, 0, None ), + #( "/Viewers/Tourney Replayer + ( "/_Database", None, None, 0, "" ), + ( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ), + ( "/Database/Create or Delete _User (todo)", None, self.dia_create_del_user, 0, None ), + ( "/Database/Create or Recreate _Tables", None, self.dia_recreate_tables, 0, None ), + ( "/Database/_Statistics (todo)", None, self.dia_database_stats, 0, None ), + ( "/D_ebugging", None, None, 0, "" ), + ( "/Debugging/_Delete Parts of Database (todo)", None, self.dia_delete_db_parts, 0, None ), + ( "/Debugging/_Export DB (todo)", None, self.dia_export_db, 0, None ), + ( "/Debugging/_Import DB (todo)", None, self.dia_import_db, 0, None ), + ( "/Debugging/_Regression test (todo)", None, self.dia_regression_test, 0, None ), + ( "/_Help", None, None, 0, "" ), + ( "/Help/_Main Help", "H", self.tab_main_help, 0, None ), + ( "/Help/_Abbrevations (todo)", None, self.tab_abbreviations, 0, None ), + ( "/Help/sep1", None, None, 0, "" ), + ( "/Help/A_bout (todo)", None, self.dia_about, 0, None ), + ( "/Help/_License and Copying (todo)", None, self.dia_licensing, 0, None ) + ) + + self.main_vbox = gtk.VBox(False, 1) + self.main_vbox.set_border_width(1) + self.window.add(self.main_vbox) + self.main_vbox.show() + + menubar = self.get_menu(self.window) + self.main_vbox.pack_start(menubar, False, True, 0) + menubar.show() + #done menubar + + self.tabs=[] + self.tab_names=[] + self.tab_buttons=[] + self.tab_box = gtk.HBox(False,1) + self.main_vbox.pack_start(self.tab_box, False, True, 0) + self.tab_box.show() + #done tab bar + + self.current_tab = gtk.VBox(False,1) + self.current_tab.set_border_width(1) + self.main_vbox.add(self.current_tab) + self.current_tab.show() + + self.tab_main_help(None, None) + + self.status_bar = gtk.Label("Status: Connected to "+self.db.get_backend_name()+" database named "+self.db.database+" on host "+self.db.host) + self.main_vbox.pack_end(self.status_bar, False, True, 0) + self.status_bar.show() + + self.window.show() + #end def __init__ + + def main(self): + gtk.main() + return 0 + #end def main + +if __name__ == "__main__": + me = fpdb() + me.main() diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py new file mode 100755 index 00000000..92a5ed86 --- /dev/null +++ b/pyfpdb/fpdb_db.py @@ -0,0 +1,172 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import os +import re +import fpdb_simple +import FpdbSQLQueries + +class fpdb_db: + def __init__(self): + """Simple constructor, doesnt really do anything""" + self.db=None + self.cursor=None + self.sql = {} + self.MYSQL_INNODB=2 + self.PGSQL=3 + self.SQLITE=4 + #end def __init__ + + def connect(self, backend, host, database, user, password): + """Connects a database with the given parameters""" + self.backend=backend + self.host=host + self.database=database + self.user=user + self.password=password + if backend==self.MYSQL_INNODB: + import MySQLdb + self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database) + elif backend==self.PGSQL: + import psycopg2 + self.db = psycopg2.connect(host = host, user = user, password = password, database = database) + else: + raise fpdb_simple.FpdbError("unrecognised database backend:"+backend) + self.cursor=self.db.cursor() + # Set up query dictionary as early in the connection process as we can. + self.sql = FpdbSQLQueries.FpdbSQLQueries(self.get_backend_name()) + self.wrongDbVersion=False + try: + self.cursor.execute("SELECT * FROM Settings") + settings=self.cursor.fetchone() + if settings[0]!=118: + print "outdated or too new database version - please recreate tables" + self.wrongDbVersion=True + except:# _mysql_exceptions.ProgrammingError: + print "failed to read settings table - please recreate tables" + self.wrongDbVersion=True + #end def connect + + def disconnect(self, due_to_error=False): + """Disconnects the DB""" + if due_to_error: + self.db.rollback() + else: + self.db.commit() + self.cursor.close() + self.db.close() + #end def disconnect + + def reconnect(self, due_to_error=False): + """Reconnects the DB""" + #print "started fpdb_db.reconnect" + self.disconnect(due_to_error) + self.connect(self.backend, self.host, self.database, self.user, self.password) + + def create_tables(self): + #todo: should detect and fail gracefully if tables already exist. + self.cursor.execute(self.sql.query['createSettingsTable']) + self.cursor.execute(self.sql.query['createSitesTable']) + self.cursor.execute(self.sql.query['createGametypesTable']) + self.cursor.execute(self.sql.query['createPlayersTable']) + self.cursor.execute(self.sql.query['createAutoratesTable']) + self.cursor.execute(self.sql.query['createHandsTable']) + self.cursor.execute(self.sql.query['createBoardCardsTable']) + self.cursor.execute(self.sql.query['createTourneyTypesTable']) + self.cursor.execute(self.sql.query['createTourneysTable']) + self.cursor.execute(self.sql.query['createTourneysPlayersTable']) + self.cursor.execute(self.sql.query['createHandsPlayersTable']) + self.cursor.execute(self.sql.query['createHandsActionsTable']) + self.cursor.execute(self.sql.query['createHudCacheTable']) + self.fillDefaultData() + self.db.commit() +#end def disconnect + + def drop_tables(self): + """Drops the fpdb tables from the current db""" + + if(self.get_backend_name() == 'MySQL InnoDB'): + #Databases with FOREIGN KEY support need this switched of before you can drop tables + self.drop_referencial_integrity() + + # Query the DB to see what tables exist + self.cursor.execute(self.sql.query['list_tables']) + for table in self.cursor: + self.cursor.execute(self.sql.query['drop_table'] + table[0]) + elif(self.get_backend_name() == 'PostgreSQL'): + self.db.commit()# I have no idea why this makes the query work--REB 07OCT2008 + self.cursor.execute(self.sql.query['list_tables']) + tables = self.cursor.fetchall() + for table in tables: + self.cursor.execute(self.sql.query['drop_table'] + table[0] + ' cascade') + elif(self.get_backend_name() == 'SQLite'): + #todo: sqlite version here + print "Empty function here" + + self.db.commit() + #end def drop_tables + + def drop_referencial_integrity(self): + """Update all tables to remove foreign keys""" + + self.cursor.execute(self.sql.query['list_tables']) + result = self.cursor.fetchall() + + for i in range(len(result)): + self.cursor.execute("SHOW CREATE TABLE " + result[i][0]) + inner = self.cursor.fetchall() + + for j in range(len(inner)): + # result[i][0] - Table name + # result[i][1] - CREATE TABLE parameters + #Searching for CONSTRAINT `tablename_ibfk_1` + for m in re.finditer('(ibfk_[0-9]+)', inner[j][1]): + key = "`" + inner[j][0] + "_" + m.group() + "`" + self.cursor.execute("ALTER TABLE " + inner[j][0] + " DROP FOREIGN KEY " + key) + self.db.commit() + #end drop_referencial_inegrity + + def get_backend_name(self): + """Returns the name of the currently used backend""" + if self.backend==2: + return "MySQL InnoDB" + elif self.backend==3: + return "PostgreSQL" + else: + raise fpdb_simple.FpdbError("invalid backend") + #end def get_backend_name + + def get_db_info(self): + return (self.host, self.database, self.user, self.password) + #end def get_db_info + + def fillDefaultData(self): + self.cursor.execute("INSERT INTO Settings VALUES (118);") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');") + self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);") + #end def fillDefaultData + + def recreate_tables(self): + """(Re-)creates the tables of the current DB""" + + self.drop_tables() + self.create_tables() + self.db.commit() + print "Finished recreating tables" + #end def recreate_tables +#end class fpdb_db diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py new file mode 100755 index 00000000..3b0fb983 --- /dev/null +++ b/pyfpdb/fpdb_import.py @@ -0,0 +1,298 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#see status.txt for site/games support info + +import sys + +try: + import MySQLdb + mysqlLibFound=True +except: + pass + +try: + import psycopg2 + pgsqlLibFound=True +except: + pass + +import math +import os +import datetime +import re +import fpdb_simple +import fpdb_parse_logic +from time import time + +class Importer: + + def __init__(self, caller, settings): + """Constructor""" + self.settings=settings + self.caller=caller + self.db = None + self.cursor = None + self.filelist = {} + self.dirlist = {} + self.monitor = False + self.updated = {} #Time last import was run {file:mtime} + self.callHud = False + self.lines = None + self.faobs = None #File as one big string + self.pos_in_file = {} # dict to remember how far we have read in the file + #Set defaults + if not self.settings.has_key('imp-callFpdbHud'): + self.settings['imp-callFpdbHud'] = False + if not self.settings.has_key('minPrint'): + self.settings['minPrint'] = 30 + self.dbConnect() + + def dbConnect(self): + #connect to DB + if self.settings['db-backend'] == 2: + if not mysqlLibFound: + raise fpdb_simple.FpdbError("interface library MySQLdb not found but MySQL selected as backend - please install the library or change the config file") + self.db = MySQLdb.connect(self.settings['db-host'], self.settings['db-user'], + self.settings['db-password'], self.settings['db-databaseName']) + elif self.settings['db-backend'] == 3: + if not pgsqlLibFound: + raise fpdb_simple.FpdbError("interface library psycopg2 not found but PostgreSQL selected as backend - please install the library or change the config file") + print self.settings + self.db = psycopg2.connect(host = self.settings['db-host'], + user = self.settings['db-user'], + password = self.settings['db-password'], + database = self.settings['db-databaseName']) + elif self.settings['db-backend'] == 4: + pass + else: + pass + self.cursor = self.db.cursor() + + #Set functions + def setCallHud(self, value): + self.callHud = value + + def setMinPrint(self, value): + self.settings['minPrint'] = int(value) + + def setHandCount(self, value): + self.settings['handCount'] = int(value) + + def setQuiet(self, value): + self.settings['quiet'] = value + + def setFailOnError(self, value): + self.settings['failOnError'] = value + +# def setWatchTime(self): +# self.updated = time() + + def clearFileList(self): + self.filelist = {} + + #Add an individual file to filelist + def addImportFile(self, filename, site = "default", filter = "passthrough"): + #TODO: test it is a valid file + self.filelist[filename] = [site] + [filter] + + #Add a directory of files to filelist + #Only one import directory per site supported. + #dirlist is a hash of lists: + #dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] } + def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"): + if os.path.isdir(dir): + if monitor == True: + self.monitor = True + self.dirlist[site] = [dir] + [filter] + + for file in os.listdir(dir): + self.addImportFile(os.path.join(dir, file), site, filter) + else: + print "Warning: Attempted to add: '" + str(dir) + "' as an import directory" + + #Run full import on filelist + def runImport(self): + for file in self.filelist: + self.import_file_dict(file) + + #Run import on updated files, then store latest update time. + def runUpdated(self): + #Check for new files in directory + #todo: make efficient - always checks for new file, should be able to use mtime of directory + # ^^ May not work on windows + for site in self.dirlist: + self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1]) + + for file in self.filelist: + stat_info = os.stat(file) + try: + lastupdate = self.updated[file] + if stat_info.st_mtime > lastupdate: + self.import_file_dict(file) + self.updated[file] = time() + except: + self.updated[file] = time() + # This codepath only runs first time the file is found, if modified in the last + # minute run an immediate import. + if (time() - stat_info.st_mtime) < 60: + self.import_file_dict(file) + + # This is now an internal function that should not be called directly. + def import_file_dict(self, file): + starttime = time() + last_read_hand=0 + loc = 0 + if (file=="stdin"): + inputFile=sys.stdin + else: + inputFile=open(file, "rU") + try: loc = self.pos_in_file[file] + except: pass + + # Read input file into class and close file + inputFile.seek(loc) + self.lines=fpdb_simple.removeTrailingEOL(inputFile.readlines()) + self.pos_in_file[file] = inputFile.tell() + inputFile.close() + + firstline = self.lines[0] + + if firstline.find("Tournament Summary")!=-1: + print "TODO: implement importing tournament summaries" + #self.faobs = readfile(inputFile) + #self.parseTourneyHistory() + return 0 + + site=fpdb_simple.recogniseSite(firstline) + category=fpdb_simple.recogniseCategory(firstline) + + startpos=0 + stored=0 #counter + duplicates=0 #counter + partial=0 #counter + errors=0 #counter + + for i in range (len(self.lines)): #main loop, iterates through the lines of a file and calls the appropriate parser method + if (len(self.lines[i])<2): + endpos=i + hand=self.lines[startpos:endpos] + + if (len(hand[0])<2): + hand=hand[1:] + + cancelled=False + damaged=False + if (site=="ftp"): + for i in range (len(hand)): + if (hand[i].endswith(" has been canceled")): #this is their typo. this is a typo, right? + cancelled=True + + seat1=hand[i].find("Seat ") #todo: make this recover by skipping this line + if (seat1!=-1): + if (hand[i].find("Seat ", seat1+3)!=-1): + damaged=True + + if (len(hand)<3): + pass + #todo: the above 2 lines are kind of a dirty hack, the mentioned circumstances should be handled elsewhere but that doesnt work with DOS/Win EOL. actually this doesnt work. + elif (hand[0].endswith(" (partial)")): #partial hand - do nothing + partial+=1 + elif (hand[1].find("Seat")==-1 and hand[2].find("Seat")==-1 and hand[3].find("Seat")==-1):#todo: should this be or instead of and? + partial+=1 + elif (cancelled or damaged): + partial+=1 + else: #normal processing + isTourney=fpdb_simple.isTourney(hand[0]) + if not isTourney: + fpdb_simple.filterAnteBlindFold(site,hand) + hand=fpdb_simple.filterCrap(site, hand, isTourney) + self.hand=hand + + try: + handsId=fpdb_parse_logic.mainParser(self.db, self.cursor, site, category, hand) + self.db.commit() + + stored+=1 + self.db.commit() +# if settings['imp-callFpdbHud'] and self.callHud and os.sep=='/': + if self.settings['imp-callFpdbHud'] and self.callHud: + #print "call to HUD here. handsId:",handsId + #pipe the Hands.id out to the HUD + self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep) + except fpdb_simple.DuplicateError: + duplicates+=1 + except (ValueError), fe: + errors+=1 + self.printEmailErrorMessage(errors, file, hand[0]) + + if (self.settings['failOnError']): + self.db.commit() #dont remove this, in case hand processing was cancelled. + raise + except (fpdb_simple.FpdbError), fe: + errors+=1 + self.printEmailErrorMessage(errors, file, hand[0]) + + #fe.printStackTrace() #todo: get stacktrace + self.db.rollback() + + if (self.settings['failOnError']): + self.db.commit() #dont remove this, in case hand processing was cancelled. + raise + if (self.settings['minPrint']!=0): + if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0): + print "stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors + + if (self.settings['handCount']!=0): + if ((stored+duplicates+partial+errors)>=self.settings['handCount']): + if (not self.settings['quiet']): + print "quitting due to reaching the amount of hands to be imported" + print "Total stored:", stored, "duplicates:", duplicates, "partial/damaged:", partial, "errors:", errors, " time:", (time() - starttime) + sys.exit(0) + startpos=endpos + print "Total stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", (time() - starttime) + + if stored==0: + if duplicates>0: + for line_no in range(len(self.lines)): + if self.lines[line_no].find("Game #")!=-1: + final_game_line=self.lines[line_no] + handsId=fpdb_simple.parseSiteHandNo(final_game_line) + else: + print "failed to read a single hand from file:", inputFile + handsId=0 + #todo: this will cause return of an unstored hand number if the last hand was error or partial + self.db.commit() + self.handsId=handsId + return handsId +#end def import_file_dict + + def parseTourneyHistory(self): + print "Tourney history parser stub" + #Find tournament boundaries. + #print self.foabs + + + def printEmailErrorMessage(self, errors, filename, line): + print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." + print "Filename:", filename + print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" + print self.hand[0] + + +if __name__ == "__main__": + print "CLI for fpdb_import is now available as CliFpdb.py" diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py new file mode 100644 index 00000000..ec9a53f6 --- /dev/null +++ b/pyfpdb/fpdb_parse_logic.py @@ -0,0 +1,164 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#methods that are specific to holdem but not trivial + +import fpdb_simple +import fpdb_save_to_db + +#parses a holdem hand +def mainParser(db, cursor, site, category, hand): + if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + base="hold" + else: + base="stud" + #part 0: create the empty arrays + lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore + lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river) + + cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[],[],[],[],[],[],[],[],[],[],[],[],[] + + #part 1: read hand no and check for duplicate + siteHandNo=fpdb_simple.parseSiteHandNo(hand[0]) + handStartTime=fpdb_simple.parseHandStartTime(hand[0], site) + siteID=fpdb_simple.recogniseSiteID(cursor, site) + #print "parse logic, siteID:",siteID,"site:",site + + isTourney=fpdb_simple.isTourney(hand[0]) + smallBlindLine=0 + for i in range(len(hand)): + if hand[i].find("posts small blind")!=-1 or hand[i].find("posts the small blind")!=-1: + smallBlindLine=i + #print "found small blind line:",smallBlindLine + break + #print "small blind line:",smallBlindLine + gametypeID=fpdb_simple.recogniseGametypeID(cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney) + if isTourney: + if site!="ps": + raise fpdb_simple.FpdbError("tourneys are only supported on PS right now") + siteTourneyNo=fpdb_simple.parseTourneyNo(hand[0]) + buyin=fpdb_simple.parseBuyin(hand[0]) + fee=fpdb_simple.parseFee(hand[0]) + entries=-1 #todo: parse this + prizepool=-1 #todo: parse this + knockout=0 + tourneyStartTime=handStartTime #todo: read tourney start time + rebuyOrAddon=fpdb_simple.isRebuyOrAddon(hand[0]) + + tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon) + fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo) + + #part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street + fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets) + + #part 3: read basic player info + #3a read player names, startcashes + for i in range (len(hand)): #todo: use maxseats+1 here. + if (lineTypes[i]=="name"): + seatLines.append(hand[i]) + names=fpdb_simple.parseNames(seatLines) + playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID) + tmp=fpdb_simple.parseCashesAndSeatNos(seatLines, site) + startCashes=tmp['startCashes'] + seatNos=tmp['seatNos'] + + fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo) + + #3b read positions + if base=="hold": + positions = fpdb_simple.parsePositions (hand, names) + + #part 4: take appropriate action for each line based on linetype + for i in range(len(hand)): + if (lineTypes[i]=="cards"): + fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits) + #if category=="studhilo": + # print "hand[i]:", hand[i] + # print "cardValues:", cardValues + # print "cardSuits:", cardSuits + elif (lineTypes[i]=="action"): + fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo) + elif (lineTypes[i]=="win"): + fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney) + elif (lineTypes[i]=="rake"): + if isTourney: + totalRake=0 + else: + totalRake=fpdb_simple.parseRake(hand[i]) + fpdb_simple.splitRake(winnings, rakes, totalRake) + elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"): + pass + elif (lineTypes[i]=="ante"): + fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes) + elif (lineTypes[i]=="table"): + tableResult=fpdb_simple.parseTableLine(site, base, hand[i]) + else: + raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i]) + if site=="ftp": + tableResult=fpdb_simple.parseTableLine(site, base, hand[0]) + maxSeats=tableResult['maxSeats'] + tableName=tableResult['tableName'] + #print "before part5, antes:", antes + + #part 5: final preparations, then call fpdb_save_to_db.* with + # the arrays as they are - that file will fill them. + fpdb_simple.convertCardValues(cardValues) + if base=="hold": + fpdb_simple.convertCardValuesBoard(boardValues) + fpdb_simple.convertBlindBet(actionTypes, actionAmounts) + fpdb_simple.checkPositions(positions) + + cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, )) + limit_type=cursor.fetchone()[0] + fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts) + + totalWinnings=0 + for i in range(len(winnings)): + totalWinnings+=winnings[i] + + if base=="hold": + hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, allIns, actionTypeByNo, winnings, totalWinnings, positions) + else: + hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, allIns, actionTypeByNo, winnings, totalWinnings, None) + + if isTourney: + ranks=[] + for i in range (len(names)): + ranks.append(0) + payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee) + + if base=="hold": + result = fpdb_save_to_db.tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID, + siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) + elif base=="stud": + result = fpdb_save_to_db.tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID, + siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, antes, cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) + else: + raise fpdb_simple.FpdbError ("unrecognised category") + else: + if base=="hold": + result = fpdb_save_to_db.ring_holdem_omaha(cursor, base, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) + elif base=="stud": + result = fpdb_save_to_db.ring_stud(cursor, base, category, siteHandNo, gametypeID, + handStartTime, names, playerIDs, startCashes, antes, cardValues, + cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) + else: + raise fpdb_simple.FpdbError ("unrecognised category") + db.commit() + return result +#end def mainParser + diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py new file mode 100644 index 00000000..af6ab09d --- /dev/null +++ b/pyfpdb/fpdb_save_to_db.py @@ -0,0 +1,94 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#This file contains methods to store hands into the db. decides to move this +#into a seperate file since its ugly, fairly long and just generally in the way. + +import fpdb_simple + +#stores a stud/razz hand into the database +def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats) + + #print "before calling store_hands_players_stud, antes:", antes + hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids, + start_cashes, antes, card_values, card_suits, winnings, rakes, seatNos) + + fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData) + + fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos) + return hands_id +#end def ring_stud + +def ring_holdem_omaha(cursor, base, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): + """stores a holdem/omaha hand into the database""" + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + fpdb_simple.fill_board_cards(board_values, board_suits) + + hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats) + + hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos) + + fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData) + + fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) + + fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos) + return hands_id +#end def ring_holdem_omaha + +def tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId, siteId, #end of tourney specific params + site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): + """stores a tourney holdem/omaha hand into the database""" + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + fpdb_simple.fill_board_cards(board_values, board_suits) + + tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start) + tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings) + + hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats) + + hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids) + + fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData) + + fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) + + fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos) + return hands_id +#end def tourney_holdem_omaha + +def tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId, + siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes, cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos): +#stores a tourney stud/razz hand into the database + fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits) + + tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime) + + tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings) + + hands_id=fpdb_simple.storeHands(cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats) + + hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, playerIds, startCashes, antes, cardValues, cardSuits, winnings, rakes, seatNos, tourneys_players_ids) + + fpdb_simple.storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData) + + fpdb_simple.storeActions(cursor, hands_players_ids, actionTypes, allIns, actionAmounts, actionNos) + return hands_id +#end def tourney_stud diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py new file mode 100644 index 00000000..d1b191de --- /dev/null +++ b/pyfpdb/fpdb_simple.py @@ -0,0 +1,2141 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#This file contains simple functions for fpdb + +import datetime +import re + +PS=1 +FTP=2 + +class DuplicateError(Exception): + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) + +class FpdbError(Exception): + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) + +#returns an array of the total money paid. intending to add rebuys/addons here +def calcPayin(count, buyin, fee): + result=[] + for i in range(count): + result.append (buyin+fee) + return result +#end def calcPayin + +def checkPositions(positions): + """verifies that these positions are valid""" + for i in range (len(positions)): + pos=positions[i] + try:#todo: use type recognition instead of error + if (len(pos)!=1): + raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+pos) #dont need to str() here + except TypeError:#->not string->is int->fine + pass + + ### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB + if (pos!="B" and pos!="S" and pos!=0 and pos!=1 and pos!=2 and pos!=3 and pos!=4 and pos!=5 and pos!=6 and pos!=7 and pos!=9): + raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+str(pos)) +#end def fpdb_simple.checkPositions + +#classifies each line for further processing in later code. Manipulates the passed arrays. +def classifyLines(hand, category, lineTypes, lineStreets): + currentStreet="predeal" + done=False #set this to true once we reach the last relevant line (the summary, except rake, is all repeats) + for i in range (len(hand)): + if (done): + if (hand[i].find("[")==-1 or hand[i].find("mucked [")==-1): + lineTypes.append("ignore") + else: #it's storing a mucked card + lineTypes.append("cards") + elif (hand[i].startswith("Dealt to")): + lineTypes.append("cards") + elif (i==0): + lineTypes.append("header") + elif (hand[i].startswith("Seat ") and ((hand[i].find("in chips")!=-1) or (hand[i].find("($")!=-1))): + lineTypes.append("name") + elif (isActionLine(hand[i])): + lineTypes.append("action") + if (hand[i].find(" posts ")!=-1 or hand[i].find(" posts the ")!=-1):#need to set this here so the "action" of posting blinds is registered properly + currentStreet="preflop" + elif (isWinLine(hand[i])): + lineTypes.append("win") + elif (hand[i].startswith("Total pot ") and hand[i].find("Rake")!=-1): + lineTypes.append("rake") + done=True + elif (hand[i]=="*** SHOW DOWN ***" or hand[i]=="*** SUMMARY ***"): + lineTypes.append("ignore") + #print "in classifyLine, showdown or summary" + elif (hand[i].find(" antes ")!=-1 or hand[i].find(" posts the ante ")!=-1): + lineTypes.append("ante") + elif (hand[i].startswith("*** FLOP *** [")): + lineTypes.append("cards") + currentStreet="flop" + elif (hand[i].startswith("*** TURN *** [")): + lineTypes.append("cards") + currentStreet="turn" + elif (hand[i].startswith("*** RIVER *** [")): + lineTypes.append("cards") + currentStreet="river" + elif (hand[i].startswith("*** 3")): + lineTypes.append("ignore") + currentStreet=0 + elif (hand[i].startswith("*** 4")): + lineTypes.append("ignore") + currentStreet=1 + elif (hand[i].startswith("*** 5")): + lineTypes.append("ignore") + currentStreet=2 + elif (hand[i].startswith("*** 6")): + lineTypes.append("ignore") + currentStreet=3 + elif (hand[i].startswith("*** 7") or hand[i]=="*** RIVER ***"): + lineTypes.append("ignore") + currentStreet=4 + elif (hand[i].find(" shows [")!=-1): + lineTypes.append("cards") + elif (hand[i].startswith("Table '")): + lineTypes.append("table") + else: + raise FpdbError("unrecognised linetype in:"+hand[i]) + lineStreets.append(currentStreet) +#end def classifyLines + +def convert3B4B(site, category, limit_type, actionTypes, actionAmounts): + """calculates the actual bet amounts in the given amount array and changes it accordingly.""" + for i in range (len(actionTypes)): + for j in range (len(actionTypes[i])): + bets=[] + for k in range (len(actionTypes[i][j])): + if (actionTypes[i][j][k]=="bet"): + bets.append((i,j,k)) + if (len(bets)==2): + #print "len(bets) 2 or higher, need to correct it. bets:",bets,"len:",len(bets) + amount2=actionAmounts[bets[1][0]][bets[1][1]][bets[1][2]] + amount1=actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]] + actionAmounts[bets[1][0]][bets[1][1]][bets[1][2]]=amount2-amount1 + elif (len(bets)>2): + fail=True + #todo: run correction for below + if (site=="ps" and category=="holdem" and limit_type=="nl" and len(bets)==3): + fail=False + if (site=="ftp" and category=="omahahi" and limit_type=="pl" and len(bets)==3): + fail=False + + if fail: + print "len(bets)>2 in convert3B4B, i didnt think this is possible. i:",i,"j:",j,"k:",k + print "actionTypes:",actionTypes + raise FpdbError ("too many bets in convert3B4B") + #print "actionAmounts postConvert",actionAmounts +#end def convert3B4B(actionTypes, actionAmounts) + +#Corrects the bet amount if the player had to pay blinds +def convertBlindBet(actionTypes, actionAmounts): + i=0#setting street to pre-flop + for j in range (len(actionTypes[i])):#playerloop + blinds=[] + bets=[] + for k in range (len(actionTypes[i][j])): + if (actionTypes[i][j][k]=="blind"): + blinds.append((i,j,k)) + + if (len(blinds)>0 and actionTypes[i][j][k]=="bet"): + bets.append((i,j,k)) + if (len(bets)==1): + blind_amount=actionAmounts[blinds[0][0]][blinds[0][1]][blinds[0][2]] + bet_amount=actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]] + actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]]=bet_amount-blind_amount +#end def convertBlindBet + +#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details +#todo: make this use convertCardValuesBoard +def convertCardValues(arr): + for i in range (len(arr)): + for j in range (len(arr[i])): + if (arr[i][j]=="A"): + arr[i][j]=14 + elif (arr[i][j]=="K"): + arr[i][j]=13 + elif (arr[i][j]=="Q"): + arr[i][j]=12 + elif (arr[i][j]=="J"): + arr[i][j]=11 + elif (arr[i][j]=="T"): + arr[i][j]=10 + else: + arr[i][j]=int(arr[i][j]) +#end def convertCardValues + +#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details +def convertCardValuesBoard(arr): + for i in range (len(arr)): + if (arr[i]=="A"): + arr[i]=14 + elif (arr[i]=="K"): + arr[i]=13 + elif (arr[i]=="Q"): + arr[i]=12 + elif (arr[i]=="J"): + arr[i]=11 + elif (arr[i]=="T"): + arr[i]=10 + else: + arr[i]=int(arr[i]) +#end def convertCardValuesBoard + +#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning. +def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo): + for i in range(seats):#create second dimension arrays + tmp=[] + card_values.append(tmp) + tmp=[] + card_suits.append(tmp) + antes.append(0) + winnings.append(0) + rakes.append(0) + + if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + streetCount=4 + else: + streetCount=5 + + for i in range(streetCount): #build the first dimension array, for streets + tmp=[] + action_types.append(tmp) + tmp=[] + allIns.append(tmp) + tmp=[] + action_amounts.append(tmp) + tmp=[] + actionNos.append(tmp) + tmp=[] + actionTypeByNo.append(tmp) + for j in range (seats): #second dimension arrays: players + tmp=[] + action_types[i].append(tmp) + tmp=[] + allIns[i].append(tmp) + tmp=[] + action_amounts[i].append(tmp) + tmp=[] + actionNos[i].append(tmp) + if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + pass + elif (category=="razz" or category=="studhi" or category=="studhilo"):#need to fill card arrays. + for i in range(seats): + for j in range (7): + card_values[i].append(0) + card_suits[i].append("x") + else: + raise FpdbError("invalid category") +#end def createArrays + +def fill_board_cards(board_values, board_suits): +#fill up the two board card arrays + while (len(board_values)<5): + board_values.append(0) + board_suits.append("x") +#end def fill_board_cards + +def fillCardArrays(player_count, base, category, card_values, card_suits): + """fills up the two card arrays""" + if (category=="holdem"): + cardCount=2 + elif (category=="omahahi" or category=="omahahilo"): + cardCount=4 + elif base=="stud": + cardCount=7 + else: + raise fpdb_simple.FpdbError ("invalid category:", category) + + for i in range (player_count): + while (len(card_values[i])=1): + raise DuplicateError ("dupl") +#end isAlreadyInDB + +def isRebuyOrAddon(topline): + """isRebuyOrAddon not implemented yet""" + return False +#end def isRebuyOrAddon + +#returns whether the passed topline indicates a tournament or not +def isTourney(topline): + if (topline.find("Tournament")!=-1): + return True + else: + return False +#end def isTourney + +#returns boolean whether the passed line is a win line +def isWinLine(line): + if (line.find("wins the pot")!=-1): + return True + elif (line.find("ties for the high pot")!=-1): + return True + elif (line.find("ties for the high main pot")!=-1): + return True + elif (line.find("ties for the high side pot")!=-1): + return True + elif (line.find("ties for the low pot")!=-1): + return True + elif (line.find("ties for the low main pot")!=-1): + return True + elif (line.find("ties for the low side pot")!=-1): + return True + elif (line.find("ties for the main pot")!=-1): #for ftp tied main pot of split pot + return True + elif (line.find("ties for the pot")!=-1): #for ftp tie + return True + elif (line.find("ties for the side pot")!=-1): #for ftp tied split pots + return True + elif (line.find("wins side pot #")!=-1): #for ftp multi split pots + return True + elif (line.find("wins the low main pot")!=-1): + return True + elif (line.find("wins the low pot")!=-1): + return True + elif (line.find("wins the low side pot")!=-1): + return True + elif (line.find("wins the high main pot")!=-1): + return True + elif (line.find("wins the high pot")!=-1): + return True + elif (line.find("wins the high side pot")!=-1): + return True + elif (line.find("wins the main pot")!=-1): + return True + elif (line.find("wins the side pot")!=-1): #for ftp split pots + return True + elif (line.find("collected")!=-1): + return True + else: + return False #not raising error here, any unknown line wouldve been detected in isActionLine already +#end def isWinLine + +#returns the amount of cash/chips put into the put in the given action line +def parseActionAmount(line, atype, site, isTourney): + #if (line.endswith(" and is all-in")): + # line=line[:-14] + #elif (line.endswith(", and is all in")): + # line=line[:-15] + + if line.endswith(", and is capped"):#ideally we should recognise this as an all-in if category is capXl + line=line[:-15] + if line.endswith(" and is capped"): + line=line[:-14] + + + if (atype=="fold"): + amount=0 + elif (atype=="check"): + amount=0 + elif (atype=="unbet" and site=="ftp"): + pos1=line.find("$")+1 + pos2=line.find(" returned to") + amount=float2int(line[pos1:pos2]) + elif (atype=="unbet" and site=="ps"): + #print "ps unbet, line:",line + pos1=line.find("$")+1 + if pos1==0: + pos1=line.find("(")+1 + pos2=line.find(")") + amount=float2int(line[pos1:pos2]) + elif (atype=="bet" and site=="ps" and line.find(": raises $")!=-1 and line.find("to $")!=-1): + pos=line.find("to $")+4 + amount=float2int(line[pos:]) + else: + if not isTourney: + pos=line.rfind("$")+1 + #print "parseActionAmount, line:", line, "line[pos:]:", line[pos:] + amount=float2int(line[pos:]) + else: + #print "line:"+line+"EOL" + pos=line.rfind(" ")+1 + #print "pos:",pos + #print "pos of 20:", line.find("20") + amount=int(line[pos:]) + + if atype=="unbet": + amount*=-1 + return amount +#end def parseActionAmount + +#doesnt return anything, simply changes the passed arrays action_types and +# action_amounts. For stud this expects numeric streets (3-7), for +# holdem/omaha it expects predeal, preflop, flop, turn or river +def parseActionLine(site, base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo): + if (street=="predeal" or street=="preflop"): + street=0 + elif (street=="flop"): + street=1 + elif (street=="turn"): + street=2 + elif (street=="river"): + street=3 + + nextActionNo=0 + for player in range(len(actionNos[street])): + for count in range(len(actionNos[street][player])): + if actionNos[street][player][count]>=nextActionNo: + nextActionNo=actionNos[street][player][count]+1 + + line, allIn=goesAllInOnThisLine(line) + atype=parseActionType(line) + playerno=recognisePlayerNo(line, names, atype) + amount=parseActionAmount(line, atype, site, isTourney) + + action_types[street][playerno].append(atype) + allIns[street][playerno].append(allIn) + action_amounts[street][playerno].append(amount) + actionNos[street][playerno].append(nextActionNo) + tmp=(playerIDs[playerno], atype) + actionTypeByNo[street].append(tmp) +#end def parseActionLine + +def goesAllInOnThisLine(line): + """returns whether the player went all-in on this line and removes the all-in text from the line.""" + isAllIn=False + if (line.endswith(" and is all-in")): + line=line[:-14] + isAllIn=True + elif (line.endswith(", and is all in")): + line=line[:-15] + isAllIn=True + return (line, isAllIn) +#end def goesAllInOnThisLine + +#returns the action type code (see table design) of the given action line +def parseActionType(line): + if (line.startswith("Uncalled bet")): + return "unbet" + elif (line.endswith("folds")): + return "fold" + elif (line.endswith("checks")): + return "check" + elif (line.find("calls")!=-1): + return "call" + elif (line.find("brings in for")!=-1): + return "blind" + elif (line.find("completes it to")!=-1): + return "bet" + #todo: what if someone completes instead of bringing in? + elif (line.find(" posts $")!=-1): + return "blind" + elif (line.find(" posts a dead ")!=-1): + return "blind" + elif (line.find(": posts small blind ")!=-1): + return "blind" + elif (line.find(" posts the small blind of $")!=-1): + return "blind" + elif (line.find(": posts big blind ")!=-1): + return "blind" + elif (line.find(" posts the big blind of $")!=-1): + return "blind" + elif (line.find(": posts small & big blinds $")!=-1): + return "blind" + #todo: seperately record voluntary blind payments made to join table out of turn + elif (line.find("bets")!=-1): + return "bet" + elif (line.find("raises")!=-1): + return "bet" + else: + raise FpdbError ("failed to recognise actiontype in parseActionLine in: "+line) +#end def parseActionType + +#parses the ante out of the given line and checks which player paid it, updates antes accordingly. +def parseAnteLine(line, site, isTourney, names, antes): + for i in range(len(names)): + if (line.startswith(names[i].encode("latin-1"))): #found the ante'er + pos=line.rfind("$")+1 + if not isTourney: + antes[i]+=float2int(line[pos:]) + else: + if line.find("all-in")==-1: + pos=line.rfind(" ")+1 + antes[i]+=int(line[pos:]) + else: + pos1=line.rfind("ante")+5 + pos2=line.find(" ",pos1) + antes[i]+=int(line[pos1:pos2]) + #print "parseAnteLine line: ", line, "antes[i]", antes[i], "antes", antes +#end def parseAntes + +#returns the buyin of a tourney in cents +def parseBuyin(topline): + pos1=topline.find("$")+1 + pos2=topline.find("+") + return float2int(topline[pos1:pos2]) +#end def parseBuyin + +#parses a card line and changes the passed arrays accordingly +#todo: reorganise this messy method +def parseCardLine(site, category, street, line, names, cardValues, cardSuits, boardValues, boardSuits): + if (line.startswith("Dealt to ") or line.find(" shows [")!=-1 or line.find("mucked [")!=-1): + playerNo=recognisePlayerNo(line, names, "card") #anything but unbet will be ok for that string + + pos=line.rfind("[")+1 + if (category=="holdem"): + for i in (pos, pos+3): + cardValues[playerNo].append(line[i:i+1]) + cardSuits[playerNo].append(line[i+1:i+2]) + if (len(cardValues[playerNo])!=2): + if cardValues[playerNo][0]==cardValues[playerNo][2] and cardSuits[playerNo][1]==cardSuits[playerNo][3]: #two tests will do + cardValues[playerNo]=cardValues[playerNo][0:2] + cardSuits[playerNo]=cardSuits[playerNo][0:2] + else: + print "line:",line,"cardValues[playerNo]:",cardValues[playerNo] + raise FpdbError("read too many/too few holecards in parseCardLine") + elif (category=="omahahi" or category=="omahahilo"): + for i in (pos, pos+3, pos+6, pos+9): + cardValues[playerNo].append(line[i:i+1]) + cardSuits[playerNo].append(line[i+1:i+2]) + if (len(cardValues[playerNo])!=4): + if cardValues[playerNo][0]==cardValues[playerNo][4] and cardSuits[playerNo][3]==cardSuits[playerNo][7]: #two tests will do + cardValues[playerNo]=cardValues[playerNo][0:4] + cardSuits[playerNo]=cardSuits[playerNo][0:4] + else: + print "line:",line,"cardValues[playerNo]:",cardValues[playerNo] + raise FpdbError("read too many/too few holecards in parseCardLine") + elif (category=="razz" or category=="studhi" or category=="studhilo"): + if (line.find("shows")==-1): + #print "parseCardLine(in stud if), street:", street + if line[pos+2]=="]": #-> not (hero and 3rd street) + cardValues[playerNo][street+2]=line[pos:pos+1] + cardSuits[playerNo][street+2]=line[pos+1:pos+2] + else: + #print "hero card1:", line[pos:pos+2], "hero card2:", line[pos+3:pos+5], "hero card3:", line[pos+6:pos+8], + cardValues[playerNo][street]=line[pos:pos+1] + cardSuits[playerNo][street]=line[pos+1:pos+2] + cardValues[playerNo][street+1]=line[pos+3:pos+4] + cardSuits[playerNo][street+1]=line[pos+4:pos+5] + cardValues[playerNo][street+2]=line[pos+6:pos+7] + cardSuits[playerNo][street+2]=line[pos+7:pos+8] + else: + #print "parseCardLine(in stud else), street:", street + cardValues[playerNo][0]=line[pos:pos+1] + cardSuits[playerNo][0]=line[pos+1:pos+2] + pos+=3 + cardValues[playerNo][1]=line[pos:pos+1] + cardSuits[playerNo][1]=line[pos+1:pos+2] + if street==4: + pos=pos=line.rfind("]")-2 + cardValues[playerNo][6]=line[pos:pos+1] + cardSuits[playerNo][6]=line[pos+1:pos+2] + #print "cardValues:", cardValues + #print "cardSuits:", cardSuits + else: + print "line:",line,"street:",street + raise FpdbError("invalid category") + #print "end of parseCardLine/playercards, cardValues:",cardValues + elif (line.startswith("*** FLOP ***")): + pos=line.find("[")+1 + for i in (pos, pos+3, pos+6): + boardValues.append(line[i:i+1]) + boardSuits.append(line[i+1:i+2]) + #print boardValues + elif (line.startswith("*** TURN ***") or line.startswith("*** RIVER ***")): + pos=line.find("[")+1 + pos=line.find("[", pos+1)+1 + boardValues.append(line[pos:pos+1]) + boardSuits.append(line[pos+1:pos+2]) + #print boardValues + else: + raise FpdbError ("unrecognised line:"+line) +#end def parseCardLine + +def parseCashesAndSeatNos(lines, site): + """parses the startCashes and seatNos of each player out of the given lines and returns them as a dictionary of two arrays""" + cashes = [] + seatNos = [] + for i in range (len(lines)): + pos2=lines[i].find(":") + seatNos.append(int(lines[i][5:pos2])) + + pos1=lines[i].rfind("($")+2 + if pos1==1: #for tourneys - it's 1 instead of -1 due to adding 2 above + pos1=lines[i].rfind("(")+1 + if (site=="ftp"): + pos2=lines[i].rfind(")") + elif (site=="ps"): + pos2=lines[i].find(" in chips") + cashes.append(float2int(lines[i][pos1:pos2])) + return {'startCashes':cashes, 'seatNos':seatNos} +#end def parseCashesAndSeatNos + +#returns the buyin of a tourney in cents +def parseFee(topline): + pos1=topline.find("$")+1 + pos1=topline.find("$",pos1)+1 + pos2=topline.find(" ", pos1) + return float2int(topline[pos1:pos2]) +#end def parsefee + +#returns a datetime object with the starttime indicated in the given topline +def parseHandStartTime(topline, site): + #convert x:13:35 to 0x:13:35 + counter=0 + while (True): + pos=topline.find(" "+str(counter)+":") + if (pos!=-1): + topline=topline[0:pos+1]+"0"+topline[pos+1:] + counter+=1 + if counter==10: break + + isUTC=False + if site=="ftp": + pos = topline.find(" ", len(topline)-26)+1 + tmp = topline[pos:] + #print "year:", tmp[14:18], "month", tmp[19:21], "day", tmp[22:24], "hour", tmp[0:2], "minute", tmp[3:5], "second", tmp[6:8] + result = datetime.datetime(int(tmp[14:18]), int(tmp[19:21]), int(tmp[22:24]), int(tmp[0:2]), int(tmp[3:5]), int(tmp[6:8])) + elif site=="ps": + if topline.find("UTC")!=-1: + pos1 = topline.find("-")+2 + pos2 = topline.find("UTC") + tmp=topline[pos1:pos2] + isUTC=True + else: + tmp=topline[-30:] + #print "parsehandStartTime, tmp:", tmp + pos = tmp.find("-")+2 + tmp = tmp[pos:] + #Need to match either + # 2008/09/07 06:23:14 ET or + # 2008/08/17 - 01:14:43 (ET) + m = re.match('(?P[0-9]{4})\/(?P[0-9]{2})\/(?P[0-9]{2})[\- ]+(?P
[0-9]{2}):(?P[0-9]{2}):(?P[0-9]{2})',tmp) + #print "year:", int(m.group('YEAR')), "month", int(m.group('MON')), "day", int(m.group('DAY')), "hour", int(m.group('HR')), "minute", int(m.group('MIN')), "second", int(m.group('SEC')) + result = datetime.datetime(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')), int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC'))) + else: + raise FpdbError("invalid site in parseHandStartTime") + + if (site=="ftp" or site=="ps") and not isUTC: #these use US ET + result+=datetime.timedelta(hours=5) + + return result +#end def parseHandStartTime + +#parses the names out of the given lines and returns them as an array +def parseNames(lines): + result = [] + for i in range (len(lines)): + pos1=lines[i].find(":")+2 + pos2=lines[i].rfind("(")-1 + tmp=lines[i][pos1:pos2] + #print "parseNames, tmp original:",tmp + tmp=unicode(tmp,"latin-1") + #print "parseNames, tmp after unicode latin-1 conversion:",tmp + result.append(tmp) + return result +#end def parseNames + +#returns an array with the positions of the respective players +def parsePositions (hand, names): + #prep array + positions=[] + for i in range(len(names)): + positions.append(-1) + + #find blinds + sb,bb=-1,-1 + for i in range (len(hand)): + if (sb==-1 and hand[i].find("small blind")!=-1 and hand[i].find("dead small blind")==-1): + sb=hand[i] + #print "sb:",sb + if (bb==-1 and hand[i].find("big blind")!=-1 and hand[i].find("dead big blind")==-1): + bb=hand[i] + #print "bb:",bb + + #identify blinds + #print "parsePositions before recognising sb/bb. names:",names + sbExists=True + if (sb!=-1): + sb=recognisePlayerNo(sb, names, "bet") + else: + sbExists=False + if (bb!=-1): + bb=recognisePlayerNo(bb, names, "bet") + + #write blinds into array + if (sbExists): + positions[sb]="S" + positions[bb]="B" + + #fill up rest of array + if (sbExists): + arraypos=sb-1 + else: + arraypos=bb-1 + distFromBtn=0 + while (arraypos>=0 and arraypos != bb): + #print "parsePositions first while, arraypos:",arraypos,"positions:",positions + positions[arraypos]=distFromBtn + arraypos-=1 + distFromBtn+=1 + + ### RHH - Changed to set the null seats before BB to "9" + i=bb-1 + while positions[i] < 0: + positions[i]=9 + i-=1 + + arraypos=len(names)-1 + if (bb!=0 or (bb==0 and sbExists==False)): + while (arraypos>bb): + positions[arraypos]=distFromBtn + arraypos-=1 + distFromBtn+=1 + + for i in range (len(names)): + if positions[i]==-1: + print "parsePositions names:",names + print "result:",positions + raise FpdbError ("failed to read positions") + return positions +#end def parsePositions + +#simply parses the rake amount and returns it as an int +def parseRake(line): + pos=line.find("Rake")+6 + rake=float2int(line[pos:]) + return rake +#end def parseRake + +def parseSiteHandNo(topline): + """returns the hand no assigned by the poker site""" + pos1=topline.find("#")+1 + pos2=topline.find(":") + return topline[pos1:pos2] +#end def parseSiteHandNo + +def parseTableLine(site, base, line): + """returns a dictionary with maxSeats and tableName""" + if site=="ps": + pos1=line.find('\'')+1 + pos2=line.find('\'', pos1) + #print "table:",line[pos1:pos2] + pos3=pos2+2 + pos4=line.find("-max") + #print "seats:",line[pos3:pos4] + return {'maxSeats':int(line[pos3:pos4]), 'tableName':line[pos1:pos2]} + elif site=="ftp": + pos1=line.find("Table ")+6 + pos2=line.find("-")-1 + if base=="hold": + maxSeats=9 + elif base=="stud": + maxSeats=8 + + if line.find("6 max")!=-1: + maxSeats=6 + elif line.find("4 max")!=-1: + maxSeats=4 + elif line.find("heads up")!=-1: + maxSeats=2 + + return {'maxSeats':maxSeats, 'tableName':line[pos1:pos2]} + else: + raise FpdbError("invalid site ID") +#end def parseTableLine + +#returns the hand no assigned by the poker site +def parseTourneyNo(topline): + pos1=topline.find("Tournament #")+12 + pos2=topline.find(",", pos1) + #print "parseTourneyNo pos1:",pos1," pos2:",pos2, " result:",topline[pos1:pos2] + return topline[pos1:pos2] +#end def parseTourneyNo + +#parses a win/collect line. manipulates the passed array winnings, no explicit return +def parseWinLine(line, site, names, winnings, isTourney): + #print "parseWinLine: line:",line + for i in range(len(names)): + if (line.startswith(names[i].encode("latin-1"))): #found a winner + if isTourney: + pos1=line.rfind("collected ")+10 + if (site=="ftp"): + pos2=line.find(")", pos1) + elif (site=="ps"): + pos2=line.find(" ", pos1) + winnings[i]+=int(line[pos1:pos2]) + else: + pos1=line.rfind("$")+1 + if (site=="ftp"): + pos2=line.find(")", pos1) + elif (site=="ps"): + pos2=line.find(" ", pos1) + winnings[i]+=float2int(line[pos1:pos2]) +#end def parseWinLine + +#returns the category (as per database) string for the given line +def recogniseCategory(line): + if (line.find("Razz")!=-1): + return "razz" + elif (line.find("Hold'em")!=-1): + return "holdem" + elif (line.find("Omaha")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1): + return "omahahi" + elif (line.find("Omaha")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)): + return "omahahilo" + elif (line.find("Stud")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1): + return "studhi" + elif (line.find("Stud")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)): + return "studhilo" + else: + raise FpdbError("failed to recognise category, line:"+line) +#end def recogniseCategory + +#returns the int for the gametype_id for the given line +def recogniseGametypeID(cursor, topline, smallBlindLine, site_id, category, isTourney):#todo: this method is messy + #if (topline.find("HORSE")!=-1): + # raise FpdbError("recogniseGametypeID: HORSE is not yet supported.") + + #note: the below variable names small_bet and big_bet are misleading, in NL/PL they mean small/big blind + if isTourney: + type="tour" + pos1=topline.find("(")+1 + if (topline[pos1]=="H" or topline[pos1]=="O" or topline[pos1]=="R" or topline[pos1]=="S" or topline[pos1+2]=="C"): + pos1=topline.find("(", pos1)+1 + pos2=topline.find("/", pos1) + small_bet=int(topline[pos1:pos2]) + else: + type="ring" + pos1=topline.find("$")+1 + pos2=topline.find("/$") + small_bet=float2int(topline[pos1:pos2]) + + pos1=pos2+2 + if isTourney: + pos1-=1 + if (site_id==1): #ftp + pos2=topline.find(" ", pos1) + elif (site_id==2): #ps + pos2=topline.find(")") + + if pos2<=pos1: + pos2=topline.find(")", pos1) + + if isTourney: + big_bet=int(topline[pos1:pos2]) + else: + big_bet=float2int(topline[pos1:pos2]) + + if (topline.find("No Limit")!=-1): + limit_type="nl" + if (topline.find("Cap No")!=-1): + limit_type="cn" + elif (topline.find("Pot Limit")!=-1): + limit_type="pl" + if (topline.find("Cap Pot")!=-1): + limit_type="cp" + else: + limit_type="fl" + + #print "recogniseGametypeID small_bet/blind:",small_bet,"big bet/blind:", big_bet,"limit type:",limit_type + if (limit_type=="fl"): + cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBet=%s AND bigBet=%s", (site_id, type, category, limit_type, small_bet, big_bet)) + else: + cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBlind=%s AND bigBlind=%s", (site_id, type, category, limit_type, small_bet, big_bet)) + result=cursor.fetchone() + #print "tried SELECTing gametypes.id, result:",result + + try: + len(result) + except TypeError: + if category=="holdem" or category=="omahahi" or category=="omahahilo": + base="hold" + else: + base="stud" + + if category=="holdem" or category=="omahahi" or category=="studhi": + hiLo='h' + elif category=="razz": + hiLo='l' + else: + hiLo='s' + + if (limit_type=="fl"): + big_blind=small_bet + if base=="hold": + if smallBlindLine==topline: + raise FpdbError("invalid small blind line") + elif isTourney: + pos=smallBlindLine.rfind(" ")+1 + small_blind=int(smallBlindLine[pos:]) + else: + pos=smallBlindLine.rfind("$")+1 + small_blind=float2int(smallBlindLine[pos:]) + else: + small_blind=0 + cursor.execute("""INSERT INTO Gametypes + (siteId, type, base, category, limitType, hiLo, smallBlind, bigBlind, smallBet, bigBet) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, type, base, category, limit_type, hiLo, small_blind, big_blind, small_bet, big_bet)) + cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBet=%s AND bigBet=%s", (site_id, type, category, limit_type, small_bet, big_bet)) + else: + cursor.execute("""INSERT INTO Gametypes + (siteId, type, base, category, limitType, hiLo, smallBlind, bigBlind, smallBet, bigBet) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, type, base, category, limit_type, hiLo, small_bet, big_bet, 0, 0))#remember, for these bet means blind + cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBlind=%s AND bigBlind=%s", (site_id, type, category, limit_type, small_bet, big_bet)) + + result=cursor.fetchone() + #print "created new gametypes.id:",result + + return result[0] +#end def recogniseGametypeID + +def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon): + cursor.execute ("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon)) + result=cursor.fetchone() + #print "tried SELECTing gametypes.id, result:",result + + try: + len(result) + except TypeError:#this means we need to create a new entry + cursor.execute("""INSERT INTO TourneyTypes (siteId, buyin, fee, knockout, rebuyOrAddon) VALUES (%s, %s, %s, %s, %s)""", (siteId, buyin, fee, knockout, rebuyOrAddon)) + cursor.execute("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon)) + result=cursor.fetchone() + return result[0] +#end def recogniseTourneyTypeId + +#returns the SQL ids of the names given in an array +def recognisePlayerIDs(cursor, names, site_id): + result = [] + for i in range (len(names)): + cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],)) + tmp=cursor.fetchall() + if (len(tmp)==0): #new player + cursor.execute ("INSERT INTO Players (name, siteId) VALUES (%s, %s)", (names[i], site_id)) + #print "Number of players rows inserted: %d" % cursor.rowcount + cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],)) + tmp=cursor.fetchall() + #print "recognisePlayerIDs, names[i]:",names[i],"tmp:",tmp + result.append(tmp[0][0]) + return result +#end def recognisePlayerIDs + +#recognises the name in the given line and returns its array position in the given array +def recognisePlayerNo(line, names, atype): + #print "recogniseplayerno, names:",names + for i in range (len(names)): + if (atype=="unbet"): + if (line.endswith(names[i].encode("latin-1"))): + return (i) + elif (line.startswith("Dealt to ")): + #print "recognisePlayerNo, card precut, line:",line + tmp=line[9:] + #print "recognisePlayerNo, card postcut, tmp:",tmp + if (tmp.startswith(names[i].encode("latin-1"))): + return (i) + elif (line.startswith("Seat ")): + if (line.startswith("Seat 10")): + tmp=line[9:] + else: + tmp=line[8:] + + if (tmp.startswith(names[i].encode("latin-1"))): + return (i) + else: + if (line.startswith(names[i].encode("latin-1"))): + return (i) + #if we're here we mustve failed + raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype) +#end def recognisePlayerNo + +#returns the site abbreviation for the given site +def recogniseSite(line): + if (line.startswith("Full Tilt Poker")): + return "ftp" + elif (line.startswith("PokerStars")): + return "ps" + else: + raise FpdbError("failed to recognise site, line:"+line) +#end def recogniseSite + +#returns the ID of the given site +def recogniseSiteID(cursor, site): + if (site=="ftp"): + return 1 + #cursor.execute("SELECT id FROM Sites WHERE name = ('Full Tilt Poker')") + elif (site=="ps"): + return 2 + #cursor.execute("SELECT id FROM Sites WHERE name = ('PokerStars')") + else: + raise FpdbError("invalid site in recogniseSiteID: "+site) + return cursor.fetchall()[0][0] +#end def recogniseSiteID + +#removes trailing \n from the given array +def removeTrailingEOL(arr): + for i in range(len(arr)): + if (arr[i].endswith("\n")): + #print "arr[i] before removetrailingEOL:", arr[i] + arr[i]=arr[i][:-1] + #print "arr[i] after removetrailingEOL:", arr[i] + return arr +#end def removeTrailingEOL + +#splits the rake according to the proportion of pot won. manipulates the second passed array. +def splitRake(winnings, rakes, totalRake): + winnercnt=0 + totalWin=0 + for i in range(len(winnings)): + if winnings[i]!=0: + winnercnt+=1 + totalWin+=winnings[i] + firstWinner=i + if winnercnt==1: + rakes[firstWinner]=totalRake + else: + totalWin=float(totalWin) + for i in range(len(winnings)): + if winnings[i]!=0: + winPortion=winnings[i]/totalWin + rakes[i]=totalRake*winPortion +#end def splitRake + +def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, actionNos): +#stores into table hands_actions + #print "start of storeActions, actionNos:",actionNos + #print " action_amounts:",action_amounts + for i in range (len(actionTypes)): #iterate through streets + for j in range (len(actionTypes[i])): #iterate through names + for k in range (len(actionTypes[i][j])): #iterate through individual actions of that player on that street + cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])) +#end def storeActions + +def store_board_cards(cursor, hands_id, board_values, board_suits): +#stores into table board_cards + cursor.execute ("""INSERT INTO BoardCards (handId, card1Value, card1Suit, + card2Value, card2Suit, card3Value, card3Suit, card4Value, card4Suit, + card5Value, card5Suit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, board_values[0], board_suits[0], board_values[1], board_suits[1], + board_values[2], board_suits[2], board_values[3], board_suits[3], + board_values[4], board_suits[4])) +#end def store_board_cards + +def storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats): +#stores into table hands + cursor.execute ("INSERT INTO Hands (siteHandNo, gametypeId, handStart, seats, tableName, importTime, maxSeats) VALUES (%s, %s, %s, %s, %s, %s, %s)", (site_hand_no, gametype_id, hand_start_time, len(names), tableName, datetime.datetime.today(), maxSeats)) + #todo: find a better way of doing this... + cursor.execute("SELECT id FROM Hands WHERE siteHandNo=%s AND gametypeId=%s", (site_hand_no, gametype_id)) + return cursor.fetchall()[0][0] +#end def storeHands + +def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos): + result=[] + if (category=="holdem"): + for i in range (len(player_ids)): + cursor.execute (""" + INSERT INTO HandsPlayers + (handId, playerId, startCash, position, + card1Value, card1Suit, card2Value, card2Suit, winnings, rake, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], positions[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + winnings[i], rakes[i], seatNos[i])) + cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) + result.append(cursor.fetchall()[0][0]) + elif (category=="omahahi" or category=="omahahilo"): + for i in range (len(player_ids)): + cursor.execute ("""INSERT INTO HandsPlayers + (handId, playerId, startCash, position, + card1Value, card1Suit, card2Value, card2Suit, + card3Value, card3Suit, card4Value, card4Suit, winnings, rake, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], positions[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], + winnings[i], rakes[i], seatNos[i])) + cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) + result.append(cursor.fetchall()[0][0]) + else: + raise FpdbError("invalid category") + return result +#end def store_hands_players_holdem_omaha + +def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes, + card_values, card_suits, winnings, rakes, seatNos): +#stores hands_players rows for stud/razz games. returns an array of the resulting IDs + result=[] + #print "before inserts in store_hands_players_stud, antes:", antes + for i in range (len(player_ids)): + cursor.execute ("""INSERT INTO HandsPlayers + (handId, playerId, startCash, ante, + card1Value, card1Suit, card2Value, card2Suit, + card3Value, card3Suit, card4Value, card4Suit, + card5Value, card5Suit, card6Value, card6Suit, + card7Value, card7Suit, winnings, rake, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], antes[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], + card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5], + card_values[i][6], card_suits[i][6], winnings[i], rakes[i], seatNos[i])) + cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) + result.append(cursor.fetchall()[0][0]) + return result +#end def store_hands_players_stud + +def store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids): +#stores hands_players for tourney holdem/omaha hands + result=[] + for i in range (len(player_ids)): + if len(card_values[0])==2: + cursor.execute ("""INSERT INTO HandsPlayers + (handId, playerId, startCash, position, + card1Value, card1Suit, card2Value, card2Suit, + winnings, rake, tourneysPlayersId, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], positions[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i])) + elif len(card_values[0])==4: + cursor.execute ("""INSERT INTO HandsPlayers + (handId, playerId, startCash, position, + card1Value, card1Suit, card2Value, card2Suit, + card3Value, card3Suit, card4Value, card4Suit, + winnings, rake, tourneysPlayersId, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], positions[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], + winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i])) + else: + raise FpdbError ("invalid card_values length:"+str(len(card_values[0]))) + cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) + result.append(cursor.fetchall()[0][0]) + + return result +#end def store_hands_players_holdem_omaha_tourney + +def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes, + antes, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids): +#stores hands_players for tourney stud/razz hands + result=[] + for i in range (len(player_ids)): + cursor.execute ("""INSERT INTO HandsPlayers + (handId, playerId, startCash, ante, + card1Value, card1Suit, card2Value, card2Suit, + card3Value, card3Suit, card4Value, card4Suit, + card5Value, card5Suit, card6Value, card6Suit, + card7Value, card7Suit, winnings, rake, tourneysPlayersId, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], antes[i], + card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], + card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], + card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5], + card_values[i][6], card_suits[i][6], winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i])) + cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) + result.append(cursor.fetchall()[0][0]) + return result +#end def store_hands_players_stud_tourney + +def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo, winnings, totalWinnings, positions): + """calculates data for the HUD during import. IMPORTANT: if you change this method make sure to also change the following storage method and table_viewer.prepare_data if necessary""" + #setup subarrays of the result dictionary. + street0VPI=[] + street0Aggr=[] + street0_3B4BChance=[] + street0_3B4BDone=[] + street1Seen=[] + street2Seen=[] + street3Seen=[] + street4Seen=[] + sawShowdown=[] + street1Aggr=[] + street2Aggr=[] + street3Aggr=[] + street4Aggr=[] + otherRaisedStreet1=[] + otherRaisedStreet2=[] + otherRaisedStreet3=[] + otherRaisedStreet4=[] + foldToOtherRaisedStreet1=[] + foldToOtherRaisedStreet2=[] + foldToOtherRaisedStreet3=[] + foldToOtherRaisedStreet4=[] + wonWhenSeenStreet1=[] + + wonAtSD=[] + stealAttemptChance=[] + stealAttempted=[] + hudDataPositions=[] + + firstPfRaiseByNo=-1 + firstPfRaiserId=-1 + firstPfRaiserNo=-1 + firstPfCallByNo=-1 + firstPfCallerId=-1 + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][1]=="bet": + firstPfRaiseByNo=i + firstPfRaiserId=actionTypeByNo[0][i][0] + for j in range(len(player_ids)): + if player_ids[j]==firstPfRaiserId: + firstPfRaiserNo=j + break + break + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][1]=="call": + firstPfCallByNo=i + firstPfCallerId=actionTypeByNo[0][i][0] + break + + cutoffId=-1 + buttonId=-1 + sbId=-1 + bbId=-1 + if base=="hold": + for player in range(len(positions)): + if positions==1: + cutoffId=player_ids[player] + if positions==0: + buttonId=player_ids[player] + if positions=='S': + sbId=player_ids[player] + if positions=='B': + bbId=player_ids[player] + + someoneStole=False + + #run a loop for each player preparing the actual values that will be commited to SQL + for player in range (len(player_ids)): + #set default values + myStreet0VPI=False + myStreet0Aggr=False + myStreet0_3B4BChance=False + myStreet0_3B4BDone=False + myStreet1Seen=False + myStreet2Seen=False + myStreet3Seen=False + myStreet4Seen=False + mySawShowdown=False + myStreet1Aggr=False + myStreet2Aggr=False + myStreet3Aggr=False + myStreet4Aggr=False + myOtherRaisedStreet1=False + myOtherRaisedStreet2=False + myOtherRaisedStreet3=False + myOtherRaisedStreet4=False + myFoldToOtherRaisedStreet1=False + myFoldToOtherRaisedStreet2=False + myFoldToOtherRaisedStreet3=False + myFoldToOtherRaisedStreet4=False + myWonWhenSeenStreet1=0.0 + myWonAtSD=0.0 + myStealAttemptChance=False + myStealAttempted=False + + #calculate VPIP and PFR + street=0 + heroPfRaiseCount=0 + for count in range (len(action_types[street][player])):#finally individual actions + currentAction=action_types[street][player][count] + if currentAction=="bet": + myStreet0Aggr=True + if (currentAction=="bet" or currentAction=="call"): + myStreet0VPI=True + + #PF3B4BChance and PF3B4B + pfFold=-1 + pfRaise=-1 + if firstPfRaiseByNo!=-1: + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][0]==player_ids[player]: + if actionTypeByNo[0][i][1]=="bet" and pfRaise==-1 and i>firstPfRaiseByNo: + pfRaise=i + if actionTypeByNo[0][i][1]=="fold" and pfFold==-1: + pfFold=i + if pfFold==-1 or pfFold>firstPfRaiseByNo: + myStreet0_3B4BChance=True + if pfRaise>firstPfRaiseByNo: + myStreet0_3B4BDone=True + + #steal calculations + if base=="hold": + if len(player_ids)>=5: #no point otherwise + if positions[player]==1: + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==buttonId or firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]==0: + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]=='S': + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]=='B': + pass + + if myStealAttempted: + someoneStole=True + + + #calculate saw* values + isAllIn=False + for i in range(len(allIns[0][player])): + if allIns[0][player][i]: + isAllIn=True + if (len(action_types[1][player])>0 or isAllIn): + myStreet1Seen=True + + for i in range(len(allIns[1][player])): + if allIns[1][player][i]: + isAllIn=True + if (len(action_types[2][player])>0 or isAllIn): + myStreet2Seen=True + + for i in range(len(allIns[2][player])): + if allIns[2][player][i]: + isAllIn=True + if (len(action_types[3][player])>0 or isAllIn): + myStreet3Seen=True + + #print "base:", base + if base=="hold": + mySawShowdown=True + for count in range (len(action_types[3][player])): + if action_types[3][player][count]=="fold": + mySawShowdown=False + else: + #print "in else" + for i in range(len(allIns[3][player])): + if allIns[3][player][i]: + isAllIn=True + if (len(action_types[4][player])>0 or isAllIn): + #print "in if" + myStreet4Seen=True + + mySawShowdown=True + for count in range (len(action_types[4][player])): + if action_types[4][player][count]=="fold": + mySawShowdown=False + + + #flop stuff + street=1 + if myStreet1Seen: + for count in range(len(action_types[street][player])): + if action_types[street][player][count]=="bet": + myStreet1Aggr=True + + for otherPlayer in range (len(player_ids)): + if player==otherPlayer: + pass + else: + for countOther in range (len(action_types[street][otherPlayer])): + if action_types[street][otherPlayer][countOther]=="bet": + myOtherRaisedStreet1=True + for countOtherFold in range (len(action_types[street][player])): + if action_types[street][player][countOtherFold]=="fold": + myFoldToOtherRaisedStreet1=True + + #turn stuff - copy of flop with different vars + street=2 + if myStreet2Seen: + for count in range(len(action_types[street][player])): + if action_types[street][player][count]=="bet": + myStreet2Aggr=True + + for otherPlayer in range (len(player_ids)): + if player==otherPlayer: + pass + else: + for countOther in range (len(action_types[street][otherPlayer])): + if action_types[street][otherPlayer][countOther]=="bet": + myOtherRaisedStreet2=True + for countOtherFold in range (len(action_types[street][player])): + if action_types[street][player][countOtherFold]=="fold": + myFoldToOtherRaisedStreet2=True + + #river stuff - copy of flop with different vars + street=3 + if myStreet3Seen: + for count in range(len(action_types[street][player])): + if action_types[street][player][count]=="bet": + myStreet3Aggr=True + + for otherPlayer in range (len(player_ids)): + if player==otherPlayer: + pass + else: + for countOther in range (len(action_types[street][otherPlayer])): + if action_types[street][otherPlayer][countOther]=="bet": + myOtherRaisedStreet3=True + for countOtherFold in range (len(action_types[street][player])): + if action_types[street][player][countOtherFold]=="fold": + myFoldToOtherRaisedStreet3=True + + #stud river stuff - copy of flop with different vars + street=4 + if myStreet4Seen: + for count in range(len(action_types[street][player])): + if action_types[street][player][count]=="bet": + myStreet4Aggr=True + + for otherPlayer in range (len(player_ids)): + if player==otherPlayer: + pass + else: + for countOther in range (len(action_types[street][otherPlayer])): + if action_types[street][otherPlayer][countOther]=="bet": + myOtherRaisedStreet4=True + for countOtherFold in range (len(action_types[street][player])): + if action_types[street][player][countOtherFold]=="fold": + myFoldToOtherRaisedStreet4=True + + if winnings[player]!=0: + if myStreet1Seen: + myWonWhenSeenStreet1=winnings[player]/float(totalWinnings) + if mySawShowdown: + myWonAtSD=myWonWhenSeenStreet1 + + #add each value to the appropriate array + street0VPI.append(myStreet0VPI) + street0Aggr.append(myStreet0Aggr) + street0_3B4BChance.append(myStreet0_3B4BChance) + street0_3B4BDone.append(myStreet0_3B4BDone) + street1Seen.append(myStreet1Seen) + street2Seen.append(myStreet2Seen) + street3Seen.append(myStreet3Seen) + street4Seen.append(myStreet4Seen) + sawShowdown.append(mySawShowdown) + street1Aggr.append(myStreet1Aggr) + street2Aggr.append(myStreet2Aggr) + street3Aggr.append(myStreet3Aggr) + street4Aggr.append(myStreet4Aggr) + otherRaisedStreet1.append(myOtherRaisedStreet1) + otherRaisedStreet2.append(myOtherRaisedStreet2) + otherRaisedStreet3.append(myOtherRaisedStreet3) + otherRaisedStreet4.append(myOtherRaisedStreet4) + foldToOtherRaisedStreet1.append(myFoldToOtherRaisedStreet1) + foldToOtherRaisedStreet2.append(myFoldToOtherRaisedStreet2) + foldToOtherRaisedStreet3.append(myFoldToOtherRaisedStreet3) + foldToOtherRaisedStreet4.append(myFoldToOtherRaisedStreet4) + wonWhenSeenStreet1.append(myWonWhenSeenStreet1) + wonAtSD.append(myWonAtSD) + stealAttemptChance.append(myStealAttemptChance) + stealAttempted.append(myStealAttempted) + if base=="hold": + pos=positions[player] + if pos=='B': + hudDataPositions.append('B') + elif pos=='S': + hudDataPositions.append('S') + elif pos==0: + hudDataPositions.append('D') + elif pos==1: + hudDataPositions.append('C') + elif pos>=2 and pos<=4: + hudDataPositions.append('M') + elif pos>=5 and pos<=7: + hudDataPositions.append('E') + ### RHH Added this elif to handle being a dead hand before the BB (pos==9) + elif pos==9: + hudDataPositions.append('X') + else: + raise FpdbError("invalid position") + elif base=="stud": + #todo: stud positions and steals + pass + + #add each array to the to-be-returned dictionary + result={'street0VPI':street0VPI} + result['street0Aggr']=street0Aggr + result['street0_3B4BChance']=street0_3B4BChance + result['street0_3B4BDone']=street0_3B4BDone + result['street1Seen']=street1Seen + result['street2Seen']=street2Seen + result['street3Seen']=street3Seen + result['street4Seen']=street4Seen + result['sawShowdown']=sawShowdown + + result['street1Aggr']=street1Aggr + result['otherRaisedStreet1']=otherRaisedStreet1 + result['foldToOtherRaisedStreet1']=foldToOtherRaisedStreet1 + result['street2Aggr']=street2Aggr + result['otherRaisedStreet2']=otherRaisedStreet2 + result['foldToOtherRaisedStreet2']=foldToOtherRaisedStreet2 + result['street3Aggr']=street3Aggr + result['otherRaisedStreet3']=otherRaisedStreet3 + result['foldToOtherRaisedStreet3']=foldToOtherRaisedStreet3 + result['street4Aggr']=street4Aggr + result['otherRaisedStreet4']=otherRaisedStreet4 + result['foldToOtherRaisedStreet4']=foldToOtherRaisedStreet4 + result['wonWhenSeenStreet1']=wonWhenSeenStreet1 + result['wonAtSD']=wonAtSD + result['stealAttemptChance']=stealAttemptChance + result['stealAttempted']=stealAttempted + + #now the various steal values + foldBbToStealChance=[] + foldedBbToSteal=[] + foldSbToStealChance=[] + foldedSbToSteal=[] + for player in range (len(player_ids)): + myFoldBbToStealChance=False + myFoldedBbToSteal=False + myFoldSbToStealChance=False + myFoldedSbToSteal=False + + if base=="hold": + if someoneStole and (positions[player]=='B' or positions[player]=='S') and firstPfRaiserId!=player_ids[player]: + street=0 + for count in range (len(action_types[street][player])):#individual actions + if positions[player]=='B': + myFoldBbToStealChance=True + if action_types[street][player][count]=="fold": + myFoldedBbToSteal=True + if positions[player]=='S': + myFoldSbToStealChance=True + if action_types[street][player][count]=="fold": + myFoldedSbToSteal=True + + + foldBbToStealChance.append(myFoldBbToStealChance) + foldedBbToSteal.append(myFoldedBbToSteal) + foldSbToStealChance.append(myFoldSbToStealChance) + foldedSbToSteal.append(myFoldedSbToSteal) + result['foldBbToStealChance']=foldBbToStealChance + result['foldedBbToSteal']=foldedBbToSteal + result['foldSbToStealChance']=foldSbToStealChance + result['foldedSbToSteal']=foldedSbToSteal + + #now CB + street1CBChance=[] + street1CBDone=[] + didStreet1CB=[] + for player in range (len(player_ids)): + myStreet1CBChance=False + myStreet1CBDone=False + + if street0VPI[player]: + myStreet1CBChance=True + if street1Aggr[player]: + myStreet1CBDone=True + didStreet1CB.append(player_ids[player]) + + street1CBChance.append(myStreet1CBChance) + street1CBDone.append(myStreet1CBDone) + result['street1CBChance']=street1CBChance + result['street1CBDone']=street1CBDone + + #now 2B + street2CBChance=[] + street2CBDone=[] + didStreet2CB=[] + for player in range (len(player_ids)): + myStreet2CBChance=False + myStreet2CBDone=False + + if street1CBDone[player]: + myStreet2CBChance=True + if street2Aggr[player]: + myStreet2CBDone=True + didStreet2CB.append(player_ids[player]) + + street2CBChance.append(myStreet2CBChance) + street2CBDone.append(myStreet2CBDone) + result['street2CBChance']=street2CBChance + result['street2CBDone']=street2CBDone + + #now 3B + street3CBChance=[] + street3CBDone=[] + didStreet3CB=[] + for player in range (len(player_ids)): + myStreet3CBChance=False + myStreet3CBDone=False + + if street2CBDone[player]: + myStreet3CBChance=True + if street3Aggr[player]: + myStreet3CBDone=True + didStreet3CB.append(player_ids[player]) + + street3CBChance.append(myStreet3CBChance) + street3CBDone.append(myStreet3CBDone) + result['street3CBChance']=street3CBChance + result['street3CBDone']=street3CBDone + + #and 4B + street4CBChance=[] + street4CBDone=[] + didStreet4CB=[] + for player in range (len(player_ids)): + myStreet4CBChance=False + myStreet4CBDone=False + + if street3CBDone[player]: + myStreet4CBChance=True + if street4Aggr[player]: + myStreet4CBDone=True + didStreet4CB.append(player_ids[player]) + + street4CBChance.append(myStreet4CBChance) + street4CBDone.append(myStreet4CBDone) + result['street4CBChance']=street4CBChance + result['street4CBDone']=street4CBDone + + + result['position']=hudDataPositions + + foldToStreet1CBChance=[] + foldToStreet1CBDone=[] + foldToStreet2CBChance=[] + foldToStreet2CBDone=[] + foldToStreet3CBChance=[] + foldToStreet3CBDone=[] + foldToStreet4CBChance=[] + foldToStreet4CBDone=[] + + for player in range (len(player_ids)): + myFoldToStreet1CBChance=False + myFoldToStreet1CBDone=False + foldToStreet1CBChance.append(myFoldToStreet1CBChance) + foldToStreet1CBDone.append(myFoldToStreet1CBDone) + + myFoldToStreet2CBChance=False + myFoldToStreet2CBDone=False + foldToStreet2CBChance.append(myFoldToStreet2CBChance) + foldToStreet2CBDone.append(myFoldToStreet2CBDone) + + myFoldToStreet3CBChance=False + myFoldToStreet3CBDone=False + foldToStreet3CBChance.append(myFoldToStreet3CBChance) + foldToStreet3CBDone.append(myFoldToStreet3CBDone) + + myFoldToStreet4CBChance=False + myFoldToStreet4CBDone=False + foldToStreet4CBChance.append(myFoldToStreet4CBChance) + foldToStreet4CBDone.append(myFoldToStreet4CBDone) + + if len(didStreet1CB)>=1: + generateFoldToCB(1, player_ids, didStreet1CB, street1CBDone, foldToStreet1CBChance, foldToStreet1CBDone, actionTypeByNo) + + if len(didStreet2CB)>=1: + generateFoldToCB(2, player_ids, didStreet2CB, street2CBDone, foldToStreet2CBChance, foldToStreet2CBDone, actionTypeByNo) + + if len(didStreet3CB)>=1: + generateFoldToCB(3, player_ids, didStreet3CB, street3CBDone, foldToStreet3CBChance, foldToStreet3CBDone, actionTypeByNo) + + if len(didStreet4CB)>=1: + generateFoldToCB(4, player_ids, didStreet4CB, street4CBDone, foldToStreet4CBChance, foldToStreet4CBDone, actionTypeByNo) + + result['foldToStreet1CBChance']=foldToStreet1CBChance + result['foldToStreet1CBDone']=foldToStreet1CBDone + result['foldToStreet2CBChance']=foldToStreet2CBChance + result['foldToStreet2CBDone']=foldToStreet2CBDone + result['foldToStreet3CBChance']=foldToStreet3CBChance + result['foldToStreet3CBDone']=foldToStreet3CBDone + result['foldToStreet4CBChance']=foldToStreet4CBChance + result['foldToStreet4CBDone']=foldToStreet4CBDone + + + totalProfit=[] + + street1CheckCallRaiseChance=[] + street1CheckCallRaiseDone=[] + street2CheckCallRaiseChance=[] + street2CheckCallRaiseDone=[] + street3CheckCallRaiseChance=[] + street3CheckCallRaiseDone=[] + street4CheckCallRaiseChance=[] + street4CheckCallRaiseDone=[] + for player in range (len(player_ids)): + myTotalProfit=0 + + myStreet1CheckCallRaiseChance=False + myStreet1CheckCallRaiseDone=False + myStreet2CheckCallRaiseChance=False + myStreet2CheckCallRaiseDone=False + myStreet3CheckCallRaiseChance=False + myStreet3CheckCallRaiseDone=False + myStreet4CheckCallRaiseChance=False + myStreet4CheckCallRaiseDone=False + + totalProfit.append(myTotalProfit) + + street1CheckCallRaiseChance.append(myStreet1CheckCallRaiseChance) + street1CheckCallRaiseDone.append(myStreet1CheckCallRaiseDone) + street2CheckCallRaiseChance.append(myStreet2CheckCallRaiseChance) + street2CheckCallRaiseDone.append(myStreet2CheckCallRaiseDone) + street3CheckCallRaiseChance.append(myStreet3CheckCallRaiseChance) + street3CheckCallRaiseDone.append(myStreet3CheckCallRaiseDone) + street4CheckCallRaiseChance.append(myStreet4CheckCallRaiseChance) + street4CheckCallRaiseDone.append(myStreet4CheckCallRaiseDone) + + result['totalProfit']=totalProfit + + result['street1CheckCallRaiseChance']=street1CheckCallRaiseChance + result['street1CheckCallRaiseDone']=street1CheckCallRaiseDone + result['street2CheckCallRaiseChance']=street2CheckCallRaiseChance + result['street2CheckCallRaiseDone']=street2CheckCallRaiseDone + result['street3CheckCallRaiseChance']=street3CheckCallRaiseChance + result['street3CheckCallRaiseDone']=street3CheckCallRaiseDone + result['street4CheckCallRaiseChance']=street4CheckCallRaiseChance + result['street4CheckCallRaiseDone']=street4CheckCallRaiseDone + return result +#end def generateHudCacheData + +def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetCBChance, foldToStreetCBDone, actionTypeByNo): + """fills the passed foldToStreetCB* arrays appropriately depending on the given street""" + #print "beginning of generateFoldToCB, street:", street, "len(actionTypeByNo):", len(actionTypeByNo) + #print "len(actionTypeByNo[street]):",len(actionTypeByNo[street]) + firstCBReaction=0 + for action in range(len(actionTypeByNo[street])): + if actionTypeByNo[street][action][1]=="bet": + for player in didStreetCB: + if player==actionTypeByNo[street][action][0] and firstCBReaction==0: + firstCBReaction=action+1 + break + + for action in actionTypeByNo[street][firstCBReaction:]: + for player in range(len(playerIDs)): + if playerIDs[player]==action[0]: + foldToStreetCBChance[player]=True + if action[1]=="fold": + foldToStreetCBDone[player]=True +#end def generateFoldToCB + +def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData): +# if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + + for player in range (len(playerIds)): + if base=="hold": + cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s", (gametypeId, playerIds[player], len(playerIds), hudImportData['position'][player])) + else: + cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s", (gametypeId, playerIds[player], len(playerIds))) + row=cursor.fetchone() + #print "gametypeId:", gametypeId, "playerIds[player]",playerIds[player], "len(playerIds):",len(playerIds), "row:",row + + try: len(row) + except TypeError: + row=[] + + if (len(row)==0): + #print "new huddata row" + doInsert=True + row=[] + row.append(0)#blank for id + row.append(gametypeId) + row.append(playerIds[player]) + row.append(len(playerIds))#seats + for i in range(len(hudImportData)+2): + row.append(0) + + else: + doInsert=False + newrow=[] + for i in range(len(row)): + newrow.append(row[i]) + row=newrow + + if base=="hold": + row[4]=hudImportData['position'][player] + else: + row[4]=0 + row[5]=1 #tourneysGametypeId + row[6]+=1 #HDs + if hudImportData['street0VPI'][player]: row[7]+=1 + if hudImportData['street0Aggr'][player]: row[8]+=1 + if hudImportData['street0_3B4BChance'][player]: row[9]+=1 + if hudImportData['street0_3B4BDone'][player]: row[10]+=1 + if hudImportData['street1Seen'][player]: row[11]+=1 + if hudImportData['street2Seen'][player]: row[12]+=1 + if hudImportData['street3Seen'][player]: row[13]+=1 + if hudImportData['street4Seen'][player]: row[14]+=1 + if hudImportData['sawShowdown'][player]: row[15]+=1 + if hudImportData['street1Aggr'][player]: row[16]+=1 + if hudImportData['street2Aggr'][player]: row[17]+=1 + if hudImportData['street3Aggr'][player]: row[18]+=1 + if hudImportData['street4Aggr'][player]: row[19]+=1 + if hudImportData['otherRaisedStreet1'][player]: row[20]+=1 + if hudImportData['otherRaisedStreet2'][player]: row[21]+=1 + if hudImportData['otherRaisedStreet3'][player]: row[22]+=1 + if hudImportData['otherRaisedStreet4'][player]: row[23]+=1 + if hudImportData['foldToOtherRaisedStreet1'][player]: row[24]+=1 + if hudImportData['foldToOtherRaisedStreet2'][player]: row[25]+=1 + if hudImportData['foldToOtherRaisedStreet3'][player]: row[26]+=1 + if hudImportData['foldToOtherRaisedStreet4'][player]: row[27]+=1 + if hudImportData['wonWhenSeenStreet1'][player]!=0.0: row[28]+=hudImportData['wonWhenSeenStreet1'][player] + if hudImportData['wonAtSD'][player]!=0.0: row[29]+=hudImportData['wonAtSD'][player] + if hudImportData['stealAttemptChance'][player]: row[30]+=1 + if hudImportData['stealAttempted'][player]: row[31]+=1 + if hudImportData['foldBbToStealChance'][player]: row[32]+=1 + if hudImportData['foldedBbToSteal'][player]: row[33]+=1 + if hudImportData['foldSbToStealChance'][player]: row[34]+=1 + if hudImportData['foldedSbToSteal'][player]: row[35]+=1 + + if hudImportData['street1CBChance'][player]: row[36]+=1 + if hudImportData['street1CBDone'][player]: row[37]+=1 + if hudImportData['street2CBChance'][player]: row[38]+=1 + if hudImportData['street2CBDone'][player]: row[39]+=1 + if hudImportData['street3CBChance'][player]: row[40]+=1 + if hudImportData['street3CBDone'][player]: row[41]+=1 + if hudImportData['street4CBChance'][player]: row[42]+=1 + if hudImportData['street4CBDone'][player]: row[43]+=1 + + if hudImportData['foldToStreet1CBChance'][player]: row[44]+=1 + if hudImportData['foldToStreet1CBDone'][player]: row[45]+=1 + if hudImportData['foldToStreet2CBChance'][player]: row[46]+=1 + if hudImportData['foldToStreet2CBDone'][player]: row[47]+=1 + if hudImportData['foldToStreet3CBChance'][player]: row[48]+=1 + if hudImportData['foldToStreet3CBDone'][player]: row[49]+=1 + if hudImportData['foldToStreet4CBChance'][player]: row[50]+=1 + if hudImportData['foldToStreet4CBDone'][player]: row[51]+=1 + + row[52]+=hudImportData['totalProfit'][player] + + if hudImportData['street1CheckCallRaiseChance'][player]: row[53]+=1 + if hudImportData['street1CheckCallRaiseDone'][player]: row[54]+=1 + if hudImportData['street2CheckCallRaiseChance'][player]: row[55]+=1 + if hudImportData['street2CheckCallRaiseDone'][player]: row[56]+=1 + if hudImportData['street3CheckCallRaiseChance'][player]: row[57]+=1 + if hudImportData['street3CheckCallRaiseDone'][player]: row[58]+=1 + if hudImportData['street4CheckCallRaiseChance'][player]: row[59]+=1 + if hudImportData['street4CheckCallRaiseDone'][player]: row[60]+=1 + + if doInsert: + #print "playerid before insert:",row[2] + cursor.execute("""INSERT INTO HudCache + (gametypeId, playerId, activeSeats, position, tourneyTypeId, + HDs, street0VPI, street0Aggr, street0_3B4BChance, street0_3B4BDone, + street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown, + street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1, + otherRaisedStreet2, otherRaisedStreet3, otherRaisedStreet4, foldToOtherRaisedStreet1, foldToOtherRaisedStreet2, + foldToOtherRaisedStreet3, foldToOtherRaisedStreet4, wonWhenSeenStreet1, wonAtSD, stealAttemptChance, + stealAttempted, foldBbToStealChance, foldedBbToSteal, foldSbToStealChance, foldedSbToSteal, + street1CBChance, street1CBDone, street2CBChance, street2CBDone, street3CBChance, + street3CBDone, street4CBChance, street4CBDone, foldToStreet1CBChance, foldToStreet1CBDone, + foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance, + foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance, + street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone) + VALUES (%s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[22], row[23], row[24], row[25], row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40], row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50], row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60])) + else: + #print "storing updated hud data line" + cursor.execute("""UPDATE HudCache + SET HDs=%s, street0VPI=%s, street0Aggr=%s, street0_3B4BChance=%s, street0_3B4BDone=%s, + street1Seen=%s, street2Seen=%s, street3Seen=%s, street4Seen=%s, sawShowdown=%s, + street1Aggr=%s, street2Aggr=%s, street3Aggr=%s, street4Aggr=%s, otherRaisedStreet1=%s, + otherRaisedStreet2=%s, otherRaisedStreet3=%s, otherRaisedStreet4=%s, foldToOtherRaisedStreet1=%s, foldToOtherRaisedStreet2=%s, + foldToOtherRaisedStreet3=%s, foldToOtherRaisedStreet4=%s, wonWhenSeenStreet1=%s, wonAtSD=%s, stealAttemptChance=%s, + stealAttempted=%s, foldBbToStealChance=%s, foldedBbToSteal=%s, foldSbToStealChance=%s, foldedSbToSteal=%s, + street1CBChance=%s, street1CBDone=%s, street2CBChance=%s, street2CBDone=%s, street3CBChance=%s, + street3CBDone=%s, street4CBChance=%s, street4CBDone=%s, foldToStreet1CBChance=%s, foldToStreet1CBDone=%s, + foldToStreet2CBChance=%s, foldToStreet2CBDone=%s, foldToStreet3CBChance=%s, foldToStreet3CBDone=%s, foldToStreet4CBChance=%s, + foldToStreet4CBDone=%s, totalProfit=%s, street1CheckCallRaiseChance=%s, street1CheckCallRaiseDone=%s, street2CheckCallRaiseChance=%s, + street2CheckCallRaiseDone=%s, street3CheckCallRaiseChance=%s, street3CheckCallRaiseDone=%s, street4CheckCallRaiseChance=%s, street4CheckCallRaiseDone=%s + WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s AND tourneyTypeId=%s""", (row[6], row[7], row[8], row[9], row[10], + row[11], row[12], row[13], row[14], row[15], + row[16], row[17], row[18], row[19], row[20], + row[21], row[22], row[23], row[24], row[25], + row[26], row[27], row[28], row[29], row[30], + row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40], + row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50], + row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60], + row[1], row[2], row[3], str(row[4]), row[5])) +# else: +# print "todo: implement storeHudCache for stud base" +#end def storeHudCache + +def store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, startTime): + cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND tourneyTypeId=%s", (siteTourneyNo, tourneyTypeId)) + tmp=cursor.fetchone() + #print "tried SELECTing tourneys.id, result:",tmp + + try: + len(tmp) + except TypeError:#means we have to create new one + cursor.execute("""INSERT INTO Tourneys + (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime) + VALUES (%s, %s, %s, %s, %s)""", (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime)) + cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND tourneyTypeId=%s", (siteTourneyNo, tourneyTypeId)) + tmp=cursor.fetchone() + #print "created new tourneys.id:",tmp + return tmp[0] +#end def store_tourneys + +def store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings): + result=[] + #print "in store_tourneys_players. tourney_id:",tourney_id + #print "player_ids:",player_ids + #print "payin_amounts:",payin_amounts + #print "ranks:",ranks + #print "winnings:",winnings + for i in range (len(player_ids)): + cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId=%s", (tourney_id, player_ids[i])) + tmp=cursor.fetchone() + #print "tried SELECTing tourneys_players.id:",tmp + + try: + len(tmp) + except TypeError: + cursor.execute("""INSERT INTO TourneysPlayers + (tourneyId, playerId, payinAmount, rank, winnings) VALUES (%s, %s, %s, %s, %s)""", + (tourney_id, player_ids[i], payin_amounts[i], ranks[i], winnings[i])) + + cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId=%s", + (tourney_id, player_ids[i])) + tmp=cursor.fetchone() + #print "created new tourneys_players.id:",tmp + result.append(tmp[0]) + return result +#end def store_tourneys_players diff --git a/regression-test/PrintHand.py b/regression-test/PrintHand.py new file mode 100755 index 00000000..c8ecf67f --- /dev/null +++ b/regression-test/PrintHand.py @@ -0,0 +1,175 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#This is intended mostly for regression testing + +import sys +import MySQLdb +from optparse import OptionParser +import fpdb_util_lib as ful + +parser = OptionParser() +parser.add_option("-n", "--handNumber", "--hand", type="int", + help="Number of the hand to print") +parser.add_option("-p", "--password", help="The password for the MySQL user") +parser.add_option("-s", "--site", default="PokerStars", + help="Name of the site (as written in the history files)") + +(options, sys.argv) = parser.parse_args() + +if options.handNumber==None or options.site==None: + print "please supply a hand number and site name. TODO: make this work" + +db = MySQLdb.connect("localhost", "fpdb", options.password, "fpdb") +cursor = db.cursor() +print "Connected to MySQL on localhost. Print Hand Utility" + +cursor.execute("SELECT id FROM Sites WHERE name=%s", (options.site,)) +siteId=cursor.fetchone()[0] +print "options.site:",options.site,"siteId:",siteId + +print "" +print "From Table Hands" +print "================" + +cursor.execute("""SELECT Hands.* FROM Hands INNER JOIN Gametypes +ON Hands.gametypeId = Gametypes.id WHERE Gametypes.siteId=%s AND Hands.siteHandNo=%s""", +(siteId, options.handNumber)) +handsResult=cursor.fetchone() +handId=handsResult[0] +tableName=handsResult[1] +siteHandNo=options.handNumber +gametypeId=handsResult[3] +handStart=handsResult[4] +#skip importTime +seats=handsResult[6] +maxSeats=handsResult[7] +print "handId:", handId, " tableName:", tableName, " siteHandNo:", siteHandNo, " gametypeId:", gametypeId, " handStart:", handStart, " seats:", seats, " maxSeats:", maxSeats + + +print "" +print "From Table Gametypes" +print "====================" + +cursor.execute("""SELECT type, base, category, limitType, hiLo FROM Gametypes WHERE id=%s""", (gametypeId, )) +typeEtc=cursor.fetchone() +type=typeEtc[0] +base=typeEtc[1] +category=typeEtc[2] +limitType=typeEtc[3] +hiLo=typeEtc[4] +print "type:", type, " base:", base, " category:", category, " limitType:", limitType, " hiLo:", hiLo + +gtString="" +doBets=False +if base=="hold": + cursor.execute("SELECT smallBlind FROM Gametypes WHERE id=%s", (gametypeId, )) + sb=cursor.fetchone()[0] + cursor.execute("SELECT bigBlind FROM Gametypes WHERE id=%s", (gametypeId, )) + bb=cursor.fetchone()[0] + gtString=("sb: "+str(sb)+" bb: "+str(bb)) + if (limitType=="fl"): + doBets=True +elif base=="stud": + doBets=True + +if doBets: + cursor.execute("SELECT smallBet FROM Gametypes WHERE id=%s", (gametypeId, )) + sbet=cursor.fetchone()[0] + cursor.execute("SELECT bigBet FROM Gametypes WHERE id=%s", (gametypeId, )) + bbet=cursor.fetchone()[0] + gtString+=(" sbet: "+str(sbet)+" bbet: "+str(bbet)) +print gtString + +if type=="ring": + pass +elif type=="tour": + #cursor.execute("SELECT tourneys_players_id FROM hands + cursor.execute("""SELECT DISTINCT TourneysPlayers.id + FROM Hands JOIN HandsPlayers ON HandsPlayers.handId=Hands.id + JOIN TourneysPlayers ON HandsPlayers.tourneysPlayersId=TourneysPlayers.id + WHERE Hands.id=%s""", (hand_id,)) + handsPlayersIds=cursor.fetchall() + print "dbg hands_players_ids:",handsPlayersIds + + print "" + print "From Table Tourneys" + print "===================" + print "TODO" + + + print "" + print "From Table TourneysPlayers" + print "==========================" + print "TODO" +else: + print "invalid type:",type + sys.exit(1) + + +print "" +print "From Table BoardCards" +print "=====================" + +if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + cursor.execute("""SELECT * FROM BoardCards WHERE handId=%s""",(handId, )) + bc=cursor.fetchone() + print "Board cards:", ful.cards2String(bc[2:]) + + +print "" +print "From Table HandsPlayers" +print "=======================" +cursor.execute("""SELECT * FROM HandsPlayers WHERE handId=%s""",(handId, )) +handsPlayers=cursor.fetchall() +playerNames=[] +for i in range (len(handsPlayers)): + line=handsPlayers[i][2:] + playerNames.append(ful.id_to_player_name(cursor, line[0])) + printstr="playerName:"+playerNames[i]+" playerStartcash:"+str(line[1]) + if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + printstr+=" position:"+ful.position2String(line[2])+" cards:" + if (category=="holdem"): + printstr+=ful.cards2String(line[5:9]) + else: + printstr+=ful.cards2String(line[5:13]) + elif (category=="razz" or category=="studhi" or category=="studhilo"): + printstr+=" ante:"+str(line[4])+" cards:" + printstr+=ful.cards2String(line[5:19]) + else: + print "TODO: raise error, print_hand.py" + sys.exit(1) + printstr+=" winnings:"+str(line[19])+" rake:"+str(line[20]) + print printstr + + +print "" +print "From Table HandsActions" +print "=======================" +for i in range (len(handsPlayers)): + cursor.execute("""SELECT * FROM HandsActions WHERE handPlayerId=%s""",(handsPlayers[i][0], )) + handsActions=cursor.fetchall() + for j in range (len(handsActions)): + line=handsActions[j][2:] + printstr="playerName:"+playerNames[i] + printstr+=" street:"+ful.street_int2String(category, line[0])+" streetActionNo:"+str(line[1])+" action:"+line[2] + printstr+=" amount:"+str(line[4]) + print printstr + +cursor.close() +db.close() +sys.exit(0) diff --git a/regression-test/PrintPlayerHudData.py b/regression-test/PrintPlayerHudData.py new file mode 100755 index 00000000..af4e60c9 --- /dev/null +++ b/regression-test/PrintPlayerHudData.py @@ -0,0 +1,158 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +#This is intended mostly for regression testing + +import sys +import MySQLdb +from optparse import OptionParser +import fpdb_util_lib as ful + +parser = OptionParser() +parser.add_option("-b", "--bigBet", default="4", type="int", help="big bet in cent") +parser.add_option("-c", "--cat", "--category", default="holdem", help="Category, e.g. holdem or studhilo") +parser.add_option("-e", "--seats", default="7", type="int", help="number of active seats") +parser.add_option("-g", "--gameType", default="ring", help="Whether its a ringgame (ring) or a tournament (tour)") +parser.add_option("-l", "--limit", "--limitType", default="fl", help="Limit Type, one of: nl, pl, fl, cn, cp") +parser.add_option("-n", "--name", "--playername", default="Player_1", help="Name of the player to print") +parser.add_option("-o", "--position", default="B", help="Position, can be B, S, D, C, M or E (see tabledesign.html)") +parser.add_option("-p", "--password", help="The password for the MySQL user") +parser.add_option("-s", "--site", default="PokerStars", help="Name of the site (as written in the history files)") + +(options, sys.argv) = parser.parse_args() + +db = MySQLdb.connect("localhost", "fpdb", options.password, "fpdb") +cursor = db.cursor() +print "Connected to MySQL on localhost. Print Player Flags Utility" + +print "" +print "Basic Data" +print "==========" +print "bigBet:",options.bigBet, "category:",options.cat, "limitType:", options.limit, "name:", options.name, "gameType:", options.gameType, "site:", options.site + +cursor.execute("SELECT id FROM Sites WHERE name=%s", (options.site,)) +siteId=cursor.fetchone()[0] + +cursor.execute("SELECT id FROM Gametypes WHERE bigBet=%s AND category=%s AND siteId=%s AND limitType=%s AND type=%s", (options.bigBet, options.cat, siteId, options.limit, options.gameType)) +gametypeId=cursor.fetchone()[0] + +cursor.execute("SELECT id FROM Players WHERE name=%s", (options.name,)) +playerId=cursor.fetchone()[0] + +#print "debug: gametypeId:", gametypeId, "playerId:", playerId, "options.seats:", options.seats, "options.position:", options.position +cursor.execute("SELECT id FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s",(gametypeId, playerId, options.seats, options.position)) +hudDataId=cursor.fetchone()[0] + +print "siteId:", siteId, "gametypeId:", gametypeId, "playerId:", playerId, "hudDataId:", hudDataId + +print "" +print "HUD Raw Hand Counts" +print "===================" + +cursor.execute ("SELECT HDs, street0VPI, street0Aggr, street0_3B4BChance, street0_3B4BDone FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "HDs:",fields[0] +print "street0VPI:",fields[1] +print "street0Aggr:",fields[2] +print "street0_3B4BChance:",fields[3] +print "street0_3B4BDone:",fields[4] +print "" + +cursor.execute ("SELECT street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "street1Seen:",fields[0] +print "street2Seen:",fields[1] +print "street3Seen:",fields[2] +print "street4Seen:",fields[3] +print "sawShowdown:",fields[4] +print "" + +cursor.execute ("SELECT street1Aggr, street2Aggr, street3Aggr, street4Aggr FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "street1Aggr:",fields[0] +print "street2Aggr:",fields[1] +print "street3Aggr:",fields[2] +print "street4Aggr:",fields[3] +print "" + +cursor.execute ("SELECT otherRaisedStreet1, otherRaisedStreet2, otherRaisedStreet3, otherRaisedStreet4, foldToOtherRaisedStreet1, foldToOtherRaisedStreet2, foldToOtherRaisedStreet3, foldToOtherRaisedStreet4 FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "otherRaisedStreet1:",fields[0] +print "otherRaisedStreet2:",fields[1] +print "otherRaisedStreet3:",fields[2] +print "otherRaisedStreet4:",fields[3] +print "foldToOtherRaisedStreet1:",fields[4] +print "foldToOtherRaisedStreet2:",fields[5] +print "foldToOtherRaisedStreet3:",fields[6] +print "foldToOtherRaisedStreet4:",fields[7] +print "" + +cursor.execute ("SELECT wonWhenSeenStreet1, wonAtSD FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "wonWhenSeenStreet1:",fields[0] +print "wonAtSD:",fields[1] + +cursor.execute ("SELECT stealAttemptChance, stealAttempted, foldBbToStealChance, foldedBbToSteal, foldSbToStealChance, foldedSbToSteal FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "stealAttemptChance:",fields[0] +print "stealAttempted:",fields[1] +print "foldBbToStealChance:",fields[2] +print "foldedBbToSteal:",fields[3] +print "foldSbToStealChance:",fields[4] +print "foldedSbToSteal:",fields[5] + +cursor.execute ("SELECT street1CBChance, street1CBDone, street2CBChance, street2CBDone, street3CBChance, street3CBDone, street4CBChance, street4CBDone FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "street1CBChance:",fields[0] +print "street1CBDone:",fields[1] +print "street2CBChance:",fields[2] +print "street2CBDone:",fields[3] +print "street3CBChance:",fields[4] +print "street3CBDone:",fields[5] +print "street4CBChance:",fields[6] +print "street4CBDone:",fields[7] + +cursor.execute ("SELECT foldToStreet1CBChance, foldToStreet1CBDone, foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance, foldToStreet4CBDone FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "foldToStreet1CBChance:",fields[0] +print "foldToStreet1CBDone:",fields[1] +print "foldToStreet2CBChance:",fields[2] +print "foldToStreet2CBDone:",fields[3] +print "foldToStreet3CBChance:",fields[4] +print "foldToStreet3CBDone:",fields[5] +print "foldToStreet4CBChance:",fields[6] +print "foldToStreet4CBDone:",fields[7] + +cursor.execute ("SELECT totalProfit FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "totalProfit:",fields[0] + +cursor.execute ("SELECT street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance, street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone FROM HudCache WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "street1CheckCallRaiseChance:",fields[0] +print "street1CheckCallRaiseDone:",fields[1] +print "street2CheckCallRaiseChance:",fields[2] +print "street2CheckCallRaiseDone:",fields[3] +print "street3CheckCallRaiseChance:",fields[4] +print "street3CheckCallRaiseDone:",fields[5] +print "street4CheckCallRaiseChance:",fields[6] +print "street4CheckCallRaiseDone:",fields[7] + + +cursor.close() +db.close() +sys.exit(0) diff --git a/regression-test/fpdb_util_lib.py b/regression-test/fpdb_util_lib.py new file mode 100644 index 00000000..a450a453 --- /dev/null +++ b/regression-test/fpdb_util_lib.py @@ -0,0 +1,80 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import sys + +def cards2String(arr): + if (len(arr)%2!=0): + print "TODO: raise error, cards2String failed, uneven length of arr" + sys.exit(1) + result = "" + for i in range (len(arr)/2): + if arr[i*2]==0: + result+="??" + else: + if arr[i*2]==14: + result+="A" + elif arr[i*2]==13: + result+="K" + elif arr[i*2]==12: + result+="Q" + elif arr[i*2]==11: + result+="J" + elif arr[i*2]==10: + result+="T" + elif (arr[i*2]>=2 and arr[i*2]<=9): + result+=str(arr[i*2]) + else: + print "TODO: raise error, cards2String failed, arr[i*2]:", arr[i*2], "len(arr):", len(arr) + print "arr:",arr + sys.exit(1) + result+=arr[i*2+1] + result+=" " + return result[:-1] + +def id_to_player_name(cursor, id): + cursor.execute("SELECT name FROM Players WHERE id=%s", (id, )) + return cursor.fetchone()[0] + +def position2String(pos): + if pos=="B": + return "BB" + elif pos=="S": + return "SB" + elif pos=="0": + return "Btn" + else: + return (pos+" off Btn") + +def street_int2String(category, street): + if (category=="holdem" or category=="omahahi" or category=="omahahilo"): + if street==0: + return "Preflop" + elif street==1: + return "Flop " + elif street==2: + return "Turn " + elif street==3: + return "River " + else: + print "TODO: raise error, fpdb_util_lib.py street_int2String invalid street no" + sys.exit(1) + elif (category=="razz" or category=="studhi" or category=="studhilo"): + return str(street) + else: + print "TODO: raise error, fpdb_util_lib.py street_int2String invalid category" + sys.exit(1) diff --git a/regression-test/known-broken/ftp-omaha-hi-pl-ring-001-005.txt b/regression-test/known-broken/ftp-omaha-hi-pl-ring-001-005.txt new file mode 100644 index 00000000..b2b4ebb6 --- /dev/null +++ b/regression-test/known-broken/ftp-omaha-hi-pl-ring-001-005.txt @@ -0,0 +1,271 @@ +Full Tilt Poker Game #6929537410: Table Green (deep) - $0.50/$1 - Pot Limit Omaha Hi - 17:15:44 ET - 2008/06/22 +Seat 1: player16 ($94.90) +Seat 2: player25 ($147) +Seat 3: player18 ($62.80) +Seat 4: player19 ($136.55) +Seat 5: play-er26 ($56.05) +Seat 6: player21 ($252.95) +Seat 7: player22 ($200) +Seat 8: player23 ($162.50) +Seat 9: player24 ($270.70) +player24 posts the small blind of $0.50 +player16 posts the big blind of $1 +player22 posts $1 +The button is in seat #8 +*** HOLE CARDS *** +player25 folds +player25 stands up +player18 folds +player19 folds +play-er26 folds +player21 folds +player22 checks +player23 calls $1 +player17 adds $100 +player24 calls $0.50 +player16 checks +*** FLOP *** [4s Kc 8s] +player24 has 15 seconds left to act +player24 checks +player16 checks +player22 checks +player23 checks +*** TURN *** [4s Kc 8s] [6s] +player24 checks +player16 checks +player22 checks +player23 bets $4 +player24 calls $4 +player16 folds +player22 folds +*** RIVER *** [4s Kc 8s 6s] [Qc] +player24 checks +player23 checks +*** SHOW DOWN *** +player23 shows [Td 5s 3d Js] a flush, Jack high +player24 mucks +player23 wins the pot ($11.40) with a flush, Jack high +*** SUMMARY *** +Total pot $12 | Rake $0.60 +Board: [4s Kc 8s 6s Qc] +Seat 1: player16 (big blind) folded on the Turn +Seat 2: player25 didn't bet (folded) +Seat 3: player18 didn't bet (folded) +Seat 4: player19 didn't bet (folded) +Seat 5: play-er26 didn't bet (folded) +Seat 6: player21 didn't bet (folded) +Seat 7: player22 folded on the Turn +Seat 8: player23 (button) collected ($11.40) +Seat 9: player24 (small blind) mucked + + + +Full Tilt Poker Game #6929553738: Table Green (deep) - $0.50/$1 - Pot Limit Omaha Hi - 17:17:06 ET - 2008/06/22 +Seat 1: player16 ($93.90) +Seat 2: player17 ($100) +Seat 3: player18 ($62.80) +Seat 4: player19 ($136.55) +Seat 5: play-er26 ($56.05) +Seat 6: player21 ($252.95) +Seat 7: player22 ($199) +Seat 8: player23 ($168.90) +Seat 9: player24 ($265.70) +player16 posts the small blind of $0.50 +player17 posts the big blind of $1 +The button is in seat #9 +*** HOLE CARDS *** +player18 folds +play-er26 stands up +player19 raises to $2 +play-er26 folds +player21 calls $2 +player22 has 15 seconds left to act +player22 folds +player23 folds +player24 folds +player16 calls $1.50 +player17 calls $1 +*** FLOP *** [Jc 4c Kc] +player16 checks +player17 checks +player19 checks +player21 checks +*** TURN *** [Jc 4c Kc] [7h] +player16 checks +player17 checks +player19 bets $3.50 +player21 folds +player16 folds +player17 calls $3.50 +*** RIVER *** [Jc 4c Kc 7h] [8s] +player17 checks +player19 has 15 seconds left to act +player19 bets $10 +player17 calls $10 +*** SHOW DOWN *** +player19 shows [4s Tc As Ac] a flush, Ace high +player17 mucks +player19 wins the pot ($33.25) with a flush, Ace high +*** SUMMARY *** +Total pot $35 | Rake $1.75 +Board: [Jc 4c Kc 7h 8s] +Seat 1: player16 (small blind) folded on the Turn +Seat 2: player17 (big blind) mucked +Seat 3: player18 didn't bet (folded) +Seat 4: player19 collected ($33.25) +Seat 5: play-er26 didn't bet (folded) +Seat 6: player21 folded on the Turn +Seat 7: player22 didn't bet (folded) +Seat 8: player23 didn't bet (folded) +Seat 9: player24 (button) didn't bet (folded) + + + +Full Tilt Poker Game #6929572212: Table Green (deep) - $0.50/$1 - Pot Limit Omaha Hi - 17:18:40 ET - 2008/06/22 +Seat 1: player16 ($91.90) +Seat 2: player17 ($84.50) +Seat 3: player18 ($62.80) +Seat 4: player19 ($154.30) +Seat 6: player21 ($250.95) +Seat 7: player22 ($199) +Seat 8: player23 ($168.90) +Seat 9: player24 ($265.70) +player17 posts the small blind of $0.50 +player18 posts the big blind of $1 +The button is in seat #1 +*** HOLE CARDS *** +player19 folds +player21 folds +player20 adds $50 +player22 folds +player23 folds +player24 folds +player20 is sitting out +player16 raises to $2 +player17 folds +player18 folds +Uncalled bet of $1 returned to player16 +player16 mucks +player16 wins the pot ($2.50) +*** SUMMARY *** +Total pot $2.50 | Rake $0 +Seat 1: player16 (button) collected ($2.50), mucked +Seat 2: player17 (small blind) folded before the Flop +Seat 3: player18 (big blind) folded before the Flop +Seat 4: player19 didn't bet (folded) +Seat 6: player21 didn't bet (folded) +Seat 7: player22 didn't bet (folded) +Seat 8: player23 didn't bet (folded) +Seat 9: player24 didn't bet (folded) + + + +Full Tilt Poker Game #6929576743: Table Green (deep) - $0.50/$1 - Pot Limit Omaha Hi - 17:19:03 ET - 2008/06/22 +Seat 1: player16 ($93.40) +Seat 2: player17 ($84) +Seat 3: player18 ($61.80) +Seat 4: player19 ($154.30) +Seat 5: player20 ($50), is sitting out +Seat 6: player21 ($250.95) +Seat 7: player22 ($199) +Seat 8: player23 ($168.90) +Seat 9: player24 ($265.70) +player18 posts the small blind of $0.50 +player19 posts the big blind of $1 +The button is in seat #2 +*** HOLE CARDS *** +player20 has returned +player21 calls $1 +player22 folds +player23 calls $1 +player24 calls $1 +player16 raises to $4 +player17 folds +player18 folds +player19 folds +player21 folds +player23 folds +player17 is sitting out +player24 has 15 seconds left to act +player24 calls $3 +*** FLOP *** [Tc 9s 7h] +player24 checks +player16 has 15 seconds left to act +player16 bets $8 +player24 folds +Uncalled bet of $8 returned to player16 +player16 mucks +player16 wins the pot ($10.95) +*** SUMMARY *** +Total pot $11.50 | Rake $0.55 +Board: [Tc 9s 7h] +Seat 1: player16 collected ($10.95), mucked +Seat 2: player17 (button) didn't bet (folded) +Seat 3: player18 (small blind) folded before the Flop +Seat 4: player19 (big blind) folded before the Flop +Seat 5: player20 is sitting out +Seat 6: player21 folded before the Flop +Seat 7: player22 didn't bet (folded) +Seat 8: player23 folded before the Flop +Seat 9: player24 folded on the Flop + + + +Full Tilt Poker Game #6929587483: Table Green (deep) - $0.50/$1 - Pot Limit Omaha Hi - 17:19:57 ET - 2008/06/22 +Seat 1: player16 ($100.35) +Seat 2: player17 ($84), is sitting out +Seat 3: player18 ($61.30) +Seat 4: player19 ($153.30) +Seat 5: player20 ($50) +Seat 6: player21 ($249.95) +Seat 7: player22 ($199) +Seat 8: player23 ($167.90) +Seat 9: player24 ($261.70) +player19 posts the small blind of $0.50 +player20 posts the big blind of $1 +The button is in seat #3 +*** HOLE CARDS *** +player21 folds +player22 folds +player21 stands up +player23 calls $1 +player24 calls $1 +player16 folds +player18 folds +player19 calls $0.50 +player20 checks +*** FLOP *** [Jd Td 2c] +roguern adds $100 +player19 bets $3 +player20 folds +player23 folds +player24 has 15 seconds left to act +player24 raises to $11 +player19 raises to $37 +player24 raises to $115 +player19 raises to $152.30, and is all in +player24 calls $37.30 +player19 shows [Jc Jh 7s 5h] +player24 shows [Kh Ad 6h Qd] +*** TURN *** [Jd Td 2c] [As] +*** RIVER *** [Jd Td 2c As] [8s] +player19 shows three of a kind, Jacks +player24 shows a straight, Ace high +player24 wins the pot ($305.60) with a straight, Ace high +player19 is sitting out +*** SUMMARY *** +Total pot $308.60 | Rake $3 +Board: [Jd Td 2c As 8s] +Seat 1: player16 didn't bet (folded) +Seat 2: player17 is sitting out +Seat 3: player18 (button) didn't bet (folded) +Seat 4: player19 (small blind) showed [Jc Jh 7s 5h] and lost with three of a kind, Jacks +Seat 5: player20 (big blind) folded on the Flop +Seat 6: player21 didn't bet (folded) +Seat 7: player22 didn't bet (folded) +Seat 8: player23 folded on the Flop +Seat 9: player24 showed [Kh Ad 6h Qd] and won ($305.60) with a straight, Ace high + + + + diff --git a/regression-test/known-broken/ftp-stud-hilo-ring-001.txt b/regression-test/known-broken/ftp-stud-hilo-ring-001.txt new file mode 100644 index 00000000..e23cb335 --- /dev/null +++ b/regression-test/known-broken/ftp-stud-hilo-ring-001.txt @@ -0,0 +1,61 @@ +Full Tilt Poker Game #6367428246: Table Mountain Mesa - $15/$30 Ante $3 - Limit Stud H/L - 23:47:38 ET - 2008/05/10 +Seat 1: Player_8 ($446), is sitting out +Seat 2: Play er9 ($303.50) +Seat 3: P layer10 ($613), is sitting out +Seat 4: Player_11 ($164) +Seat 5: Player1 2 ($543.50), is sitting out +Seat 6: Player13 ($912.50) +Seat 7: Player14 ($430), is sitting out +Seat 8: Player15 ($531.50) +Player15 antes $3 +Player_11 antes $3 +Player13 antes $3 +Play er9 antes $3 +*** 3RD STREET *** +Dealt to Play er9 [2s] +Dealt to Player_11 [3c] +Dealt to Player13 [8c] +Dealt to Player15 [Jc] +Play er9 is low with [2s] +Play er9 brings in for $5 +Player_11 folds +Player13 completes it to $15 +Player15 folds +Play er9 calls $10 +*** 4TH STREET *** +Dealt to Play er9 [2s] [6c] +Dealt to Player13 [8c] [5h] +Player13 bets $15 +Play er9 calls $15 +*** 5TH STREET *** +Dealt to Play er9 [2s 6c] [Ac] +Dealt to Player13 [8c 5h] [Ah] +Player13 bets $30 +Play er9 calls $30 +*** 6TH STREET *** +Dealt to Play er9 [2s 6c Ac] [2c] +Dealt to Player13 [8c 5h Ah] [Jd] +Play er9 bets $30 +Player13 calls $30 +*** 7TH STREET *** +Play er9 bets $30 +Player13 calls $30 +*** SHOW DOWN *** +Play er9 shows [5c 4h 2s 6c Ac 2c 2h] three of a kind, Twos, for high and 6,5,4,2,A, for low +Player13 mucks +Play er9 wins the high pot ($125) with three of a kind, Twos +Play er9 wins the low pot ($125) with 6,5,4,2,A +*** SUMMARY *** +Total pot $252 | Rake $2 +Seat 1: Player_8 is sitting out +Seat 2: Play er9 collected ($250) +Seat 3: P layer10 is sitting out +Seat 4: Player_11 folded on 3rd St. +Seat 5: Player1 2 is sitting out +Seat 6: Player13 mucked +Seat 7: Player14 is sitting out +Seat 8: Player15 folded on 3rd St. + + + + diff --git a/regression-test/known-broken/ftp.6367428246.expected.txt b/regression-test/known-broken/ftp.6367428246.expected.txt new file mode 100644 index 00000000..2e88061c --- /dev/null +++ b/regression-test/known-broken/ftp.6367428246.expected.txt @@ -0,0 +1,40 @@ +This file is outdated! + +Connected to MySQL on localhost. Print Hand Utility +options.site: Full Tilt Poker site_id: 1 + +From Table sites +==================== +site_name: Full Tilt Poker + +From Table gametypes +==================== +type: category: studhilo limit_type: +sb: bb: sbet: bbet: + +From Table hands +================ +site_hand_no: 6367428246 hand_start: 2008-05-11 04:47:38 seat_count: 4 + +From Table hands_players +======================== +player_name:Play er9 player_startcash:30350 ante:300 cards:5c 4h 2s 6c Ac 2c 2h winnings:25000 rake:200 +player_name:Player_11 player_startcash:16400 ante:300 cards:?? ?? 3c ?? ?? ?? ?? winnings:0 rake:0 +player_name:Player13 player_startcash:91250 ante:300 cards:?? ?? 8c 5h Ah Jd ?? winnings:0 rake:0 +player_name:Player15 player_startcash:53150 ante:300 cards:?? ?? Jc ?? ?? ?? ?? winnings:0 rake:0 + +From Table hands_actions +======================== +player_name:Play er9 actionCount:0 street:3 streetActionNo:0 action:blind amount:500 +player_name:Play er9 actionCount:1 street:3 streetActionNo:1 action:call amount:1000 +player_name:Play er9 actionCount:2 street:4 streetActionNo:0 action:call amount:1500 +player_name:Play er9 actionCount:3 street:5 streetActionNo:0 action:call amount:3000 +player_name:Play er9 actionCount:4 street:6 streetActionNo:0 action:bet amount:3000 +player_name:Play er9 actionCount:5 street:7 streetActionNo:0 action:bet amount:3000 +player_name:Player_11 actionCount:0 street:3 streetActionNo:0 action:fold amount:0 +player_name:Player13 actionCount:0 street:3 streetActionNo:0 action:bet amount:1500 +player_name:Player13 actionCount:1 street:4 streetActionNo:0 action:bet amount:1500 +player_name:Player13 actionCount:2 street:5 streetActionNo:0 action:bet amount:3000 +player_name:Player13 actionCount:3 street:6 streetActionNo:0 action:call amount:3000 +player_name:Player13 actionCount:4 street:7 streetActionNo:0 action:call amount:3000 +player_name:Player15 actionCount:0 street:3 streetActionNo:0 action:fold amount:0 diff --git a/regression-test/known-broken/ftp.6929537410.expected.txt b/regression-test/known-broken/ftp.6929537410.expected.txt new file mode 100644 index 00000000..6d558420 --- /dev/null +++ b/regression-test/known-broken/ftp.6929537410.expected.txt @@ -0,0 +1,48 @@ +This file is outdated! + +Connected to MySQL on localhost. Print Hand Utility +options.site: Full Tilt Poker site_id: 1 +From Table hands +================ +site_hand_no: 6929537410 hand_start: 2008-06-22 22:15:44 seat_count: 9 category: omahahi +Board cards: 4s Kc 8s 6s Qc + +From Table hands_players +======================== +player_name:player16 player_startcash:9490 position:BB cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player25 player_startcash:14700 position:6 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player18 player_startcash:6280 position:5 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player19 player_startcash:13655 position:4 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:play-er26 player_startcash:5605 position:3 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player21 player_startcash:25295 position:2 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player22 player_startcash:20000 position:1 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player23 player_startcash:16250 position:Btn cards:Td 5s 3d Js winnings:1140 rake:60 +player_name:player24 player_startcash:27070 position:SB cards:?? ?? ?? ?? winnings:0 rake:0 + +From Table hands_actions +======================== +player_name:player16 actionCount:0 street:Preflop streetActionNo:0 action:blind amount:100 +player_name:player16 actionCount:1 street:Preflop streetActionNo:1 action:check amount:0 +player_name:player16 actionCount:2 street:Flop streetActionNo:0 action:check amount:0 +player_name:player16 actionCount:3 street:Turn streetActionNo:0 action:check amount:0 +player_name:player16 actionCount:4 street:Turn streetActionNo:1 action:fold amount:0 +player_name:player25 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player18 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player19 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:play-er26 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player21 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player22 actionCount:0 street:Preflop streetActionNo:0 action:blind amount:100 +player_name:player22 actionCount:1 street:Preflop streetActionNo:1 action:check amount:0 +player_name:player22 actionCount:2 street:Flop streetActionNo:0 action:check amount:0 +player_name:player22 actionCount:3 street:Turn streetActionNo:0 action:check amount:0 +player_name:player22 actionCount:4 street:Turn streetActionNo:1 action:fold amount:0 +player_name:player23 actionCount:0 street:Preflop streetActionNo:0 action:call amount:100 +player_name:player23 actionCount:1 street:Flop streetActionNo:0 action:check amount:0 +player_name:player23 actionCount:2 street:Turn streetActionNo:0 action:bet amount:400 +player_name:player23 actionCount:3 street:River streetActionNo:0 action:check amount:0 +player_name:player24 actionCount:0 street:Preflop streetActionNo:0 action:blind amount:50 +player_name:player24 actionCount:1 street:Preflop streetActionNo:1 action:call amount:50 +player_name:player24 actionCount:2 street:Flop streetActionNo:0 action:check amount:0 +player_name:player24 actionCount:3 street:Turn streetActionNo:0 action:check amount:0 +player_name:player24 actionCount:4 street:Turn streetActionNo:1 action:call amount:400 +player_name:player24 actionCount:5 street:River streetActionNo:0 action:check amount:0 diff --git a/regression-test/known-broken/ftp.6929553738.expected.txt b/regression-test/known-broken/ftp.6929553738.expected.txt new file mode 100644 index 00000000..b758cbfc --- /dev/null +++ b/regression-test/known-broken/ftp.6929553738.expected.txt @@ -0,0 +1,47 @@ +This file is outdated! + +Connected to MySQL on localhost. Print Hand Utility +options.site: Full Tilt Poker site_id: 1 +From Table hands +================ +site_hand_no: 6929553738 hand_start: 2008-06-22 22:17:06 seat_count: 9 category: omahahi +Board cards: Jc 4c Kc 7h 8s + +From Table hands_players +======================== +player_name:player16 player_startcash:9390 position:SB cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player17 player_startcash:10000 position:BB cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player18 player_startcash:6280 position:6 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player19 player_startcash:13655 position:5 off Btn cards:4s Tc As Ac winnings:3325 rake:175 +player_name:play-er26 player_startcash:5605 position:4 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player21 player_startcash:25295 position:3 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player22 player_startcash:19900 position:2 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player23 player_startcash:16890 position:1 off Btn cards:?? ?? ?? ?? winnings:0 rake:0 +player_name:player24 player_startcash:26570 position:Btn cards:?? ?? ?? ?? winnings:0 rake:0 + +From Table hands_actions +======================== +player_name:player16 actionCount:0 street:Preflop streetActionNo:0 action:blind amount:50 +player_name:player16 actionCount:1 street:Preflop streetActionNo:1 action:call amount:150 +player_name:player16 actionCount:2 street:Flop streetActionNo:0 action:check amount:0 +player_name:player16 actionCount:3 street:Turn streetActionNo:0 action:check amount:0 +player_name:player16 actionCount:4 street:Turn streetActionNo:1 action:fold amount:0 +player_name:player17 actionCount:0 street:Preflop streetActionNo:0 action:blind amount:100 +player_name:player17 actionCount:1 street:Preflop streetActionNo:1 action:call amount:100 +player_name:player17 actionCount:2 street:Flop streetActionNo:0 action:check amount:0 +player_name:player17 actionCount:3 street:Turn streetActionNo:0 action:check amount:0 +player_name:player17 actionCount:4 street:Turn streetActionNo:1 action:call amount:350 +player_name:player17 actionCount:5 street:River streetActionNo:0 action:check amount:0 +player_name:player17 actionCount:6 street:River streetActionNo:1 action:call amount:1000 +player_name:player18 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player19 actionCount:0 street:Preflop streetActionNo:0 action:bet amount:200 +player_name:player19 actionCount:1 street:Flop streetActionNo:0 action:check amount:0 +player_name:player19 actionCount:2 street:Turn streetActionNo:0 action:bet amount:350 +player_name:player19 actionCount:3 street:River streetActionNo:0 action:bet amount:1000 +player_name:play-er26 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player21 actionCount:0 street:Preflop streetActionNo:0 action:call amount:200 +player_name:player21 actionCount:1 street:Flop streetActionNo:0 action:check amount:0 +player_name:player21 actionCount:2 street:Turn streetActionNo:0 action:fold amount:0 +player_name:player22 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player23 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 +player_name:player24 actionCount:0 street:Preflop streetActionNo:0 action:fold amount:0 diff --git a/regression-test/mysql-dump.sql b/regression-test/mysql-dump.sql new file mode 100644 index 00000000..7f92c777 --- /dev/null +++ b/regression-test/mysql-dump.sql @@ -0,0 +1,376 @@ +-- MySQL dump 10.11 +-- +-- Host: localhost Database: fpdb +-- ------------------------------------------------------ +-- Server version 5.0.54-log + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `autorates` +-- + +DROP TABLE IF EXISTS `autorates`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `autorates` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `player_id` int(10) unsigned default NULL, + `gametype_id` smallint(5) unsigned default NULL, + `description` varchar(50) default NULL, + `short_desc` char(8) default NULL, + `rating_time` datetime default NULL, + `hand_count` int(11) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `player_id` (`player_id`), + KEY `gametype_id` (`gametype_id`), + CONSTRAINT `autorates_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`), + CONSTRAINT `autorates_ibfk_2` FOREIGN KEY (`gametype_id`) REFERENCES `gametypes` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `autorates` +-- + +LOCK TABLES `autorates` WRITE; +/*!40000 ALTER TABLE `autorates` DISABLE KEYS */; +/*!40000 ALTER TABLE `autorates` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `board_cards` +-- + +DROP TABLE IF EXISTS `board_cards`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `board_cards` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `hand_id` bigint(20) unsigned default NULL, + `card1_value` smallint(6) default NULL, + `card1_suit` char(1) default NULL, + `card2_value` smallint(6) default NULL, + `card2_suit` char(1) default NULL, + `card3_value` smallint(6) default NULL, + `card3_suit` char(1) default NULL, + `card4_value` smallint(6) default NULL, + `card4_suit` char(1) default NULL, + `card5_value` smallint(6) default NULL, + `card5_suit` char(1) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `hand_id` (`hand_id`), + CONSTRAINT `board_cards_ibfk_1` FOREIGN KEY (`hand_id`) REFERENCES `hands` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `board_cards` +-- + +LOCK TABLES `board_cards` WRITE; +/*!40000 ALTER TABLE `board_cards` DISABLE KEYS */; +INSERT INTO `board_cards` VALUES (1,1,12,'d',10,'h',11,'s',2,'s',7,'s'),(2,2,10,'h',11,'d',3,'c',7,'c',4,'s'),(3,3,4,'h',9,'s',14,'d',12,'c',13,'s'),(4,5,4,'s',13,'c',8,'s',6,'s',12,'c'),(5,6,11,'c',4,'c',13,'c',7,'h',8,'s'),(6,7,0,'x',0,'x',0,'x',0,'x',0,'x'),(7,8,10,'c',9,'s',7,'h',0,'x',0,'x'),(8,9,11,'d',10,'d',2,'c',14,'s',8,'s'); +/*!40000 ALTER TABLE `board_cards` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gametypes` +-- + +DROP TABLE IF EXISTS `gametypes`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `gametypes` ( + `id` smallint(5) unsigned NOT NULL auto_increment, + `site_id` smallint(5) unsigned default NULL, + `type` char(4) default NULL, + `category` varchar(9) default NULL, + `limit_type` char(2) default NULL, + `max_seats` smallint(6) default NULL, + `small_blind` int(11) default NULL, + `big_blind` int(11) default NULL, + `small_bet` int(11) default NULL, + `big_bet` int(11) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `site_id` (`site_id`), + CONSTRAINT `gametypes_ibfk_1` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `gametypes` +-- + +LOCK TABLES `gametypes` WRITE; +/*!40000 ALTER TABLE `gametypes` DISABLE KEYS */; +INSERT INTO `gametypes` VALUES (1,1,'ring','holdem','fl',10,10,25,25,50),(2,1,'ring','holdem','fl',10,25,50,50,100),(3,1,'ring','holdem','fl',10,50,100,100,200),(4,1,'ring','holdem','fl',10,100,200,200,400),(5,1,'ring','holdem','fl',10,150,300,300,600),(6,1,'ring','holdem','fl',10,250,500,500,1000),(7,1,'ring','holdem','fl',10,400,800,800,1600),(8,1,'ring','holdem','fl',10,500,1000,1000,2000),(9,1,'ring','holdem','fl',10,1000,1500,1500,3000),(10,1,'ring','holdem','fl',10,1500,3000,3000,6000),(11,1,'ring','omahahi','pl',10,5,10,0,0),(12,1,'ring','omahahi','pl',10,10,25,0,0),(13,1,'ring','omahahi','pl',10,25,50,0,0),(14,1,'ring','omahahi','pl',10,50,100,0,0),(15,1,'ring','omahahi','pl',10,100,200,0,0),(16,1,'ring','omahahi','pl',10,200,400,0,0),(17,1,'ring','omahahi','pl',10,1000,2000,0,0),(18,1,'ring','omahahi','cp',10,2500,5000,0,0),(19,1,'ring','omahahilo','fl',10,10,25,25,50),(20,1,'ring','omahahilo','fl',10,50,100,100,200),(21,1,'ring','omahahilo','fl',10,150,300,300,600),(22,1,'ring','omahahilo','fl',10,250,500,500,1000),(23,1,'ring','omahahilo','pl',10,10,25,0,0),(24,1,'ring','omahahilo','pl',10,50,100,0,0),(25,1,'ring','omahahilo','pl',10,100,200,0,0),(26,1,'ring','omahahilo','nl',10,5,10,0,0),(27,1,'ring','omahahilo','nl',10,50,100,0,0),(28,1,'ring','omahahilo','nl',10,100,200,0,0),(29,1,'ring','razz','fl',8,0,0,25,50),(30,1,'ring','razz','fl',8,0,0,50,100),(31,1,'ring','razz','fl',8,0,0,100,200),(32,1,'ring','razz','fl',8,0,0,200,400),(33,1,'ring','razz','fl',8,0,0,300,600),(34,1,'ring','razz','fl',8,0,0,500,1000),(35,1,'ring','razz','fl',8,0,0,800,1600),(36,1,'ring','razz','fl',8,0,0,1500,3000),(37,1,'ring','razz','fl',8,0,0,2000,4000),(38,1,'ring','razz','fl',8,0,0,3000,6000),(39,1,'ring','razz','fl',8,0,0,10000,20000),(40,1,'ring','studhi','fl',8,0,0,25,50),(41,1,'ring','studhi','fl',8,0,0,200,400),(42,1,'ring','studhi','fl',8,0,0,300,600),(43,1,'ring','studhi','fl',8,0,0,500,1000),(44,1,'ring','studhilo','fl',8,0,0,50,100),(45,1,'ring','studhilo','fl',8,0,0,100,200),(46,1,'ring','studhilo','fl',8,0,0,1500,3000),(47,2,'ring','holdem','fl',10,1,2,2,4),(48,2,'ring','holdem','fl',10,2,5,5,10),(49,2,'ring','holdem','fl',10,5,10,10,20),(50,2,'ring','holdem','fl',10,10,25,25,50),(51,2,'ring','holdem','nl',10,1,2,0,0),(52,2,'ring','holdem','nl',10,2,5,0,0),(53,2,'ring','holdem','nl',10,5,10,0,0),(54,2,'ring','omahahi','pl',10,1,2,0,0),(55,2,'ring','omahahi','pl',10,10,25,0,0),(56,2,'ring','omahahilo','fl',10,1,2,2,4),(57,2,'ring','omahahilo','pl',10,1,2,0,0),(58,2,'ring','razz','fl',8,0,0,50,100),(59,2,'tour','razz','fl',8,0,0,10,20),(60,2,'ring','studhi','fl',8,0,0,4,8),(61,2,'ring','studhi','fl',8,0,0,10,20),(62,2,'ring','studhilo','fl',8,0,0,4,8),(63,2,'ring','studhilo','fl',8,0,0,10,20),(64,2,'ring','studhilo','fl',8,0,0,25,50),(65,2,'ring','studhilo','fl',8,0,0,50,100); +/*!40000 ALTER TABLE `gametypes` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `hands` +-- + +DROP TABLE IF EXISTS `hands`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `hands` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `site_hand_no` bigint(20) default NULL, + `gametype_id` smallint(5) unsigned default NULL, + `hand_start` datetime default NULL, + `seats` smallint(6) default NULL, + `comment` text, + `comment_ts` datetime default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `gametype_id` (`gametype_id`), + CONSTRAINT `hands_ibfk_1` FOREIGN KEY (`gametype_id`) REFERENCES `gametypes` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `hands` +-- + +LOCK TABLES `hands` WRITE; +/*!40000 ALTER TABLE `hands` DISABLE KEYS */; +INSERT INTO `hands` VALUES (1,14519394979,47,'2008-01-13 05:22:15',7,NULL,NULL),(2,14519420999,47,'2008-01-13 05:23:43',7,NULL,NULL),(3,14519433154,47,'2008-01-13 05:24:25',7,NULL,NULL),(4,6367428246,46,'2008-05-11 04:47:38',4,NULL,NULL),(5,6929537410,14,'2008-06-22 22:15:44',9,NULL,NULL),(6,6929553738,14,'2008-06-22 22:17:06',9,NULL,NULL),(7,6929572212,14,'2008-06-22 22:18:40',8,NULL,NULL),(8,6929576743,14,'2008-06-22 22:19:03',8,NULL,NULL),(9,6929587483,14,'2008-06-22 22:19:57',8,NULL,NULL); +/*!40000 ALTER TABLE `hands` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `hands_actions` +-- + +DROP TABLE IF EXISTS `hands_actions`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `hands_actions` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `hand_player_id` bigint(20) unsigned default NULL, + `street` smallint(6) default NULL, + `action_no` smallint(6) default NULL, + `action` char(5) default NULL, + `amount` int(11) default NULL, + `comment` text, + `comment_ts` datetime default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `hand_player_id` (`hand_player_id`), + CONSTRAINT `hands_actions_ibfk_1` FOREIGN KEY (`hand_player_id`) REFERENCES `hands_players` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=181 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `hands_actions` +-- + +LOCK TABLES `hands_actions` WRITE; +/*!40000 ALTER TABLE `hands_actions` DISABLE KEYS */; +INSERT INTO `hands_actions` VALUES (1,1,0,0,'call',4,NULL,NULL),(2,2,0,0,'blind',1,NULL,NULL),(3,2,0,1,'call',3,NULL,NULL),(4,3,0,0,'blind',2,NULL,NULL),(5,3,0,1,'fold',0,NULL,NULL),(6,4,0,0,'bet',4,NULL,NULL),(7,5,0,0,'fold',0,NULL,NULL),(8,6,0,0,'fold',0,NULL,NULL),(9,7,0,0,'fold',0,NULL,NULL),(10,1,1,0,'call',2,NULL,NULL),(11,2,1,0,'check',0,NULL,NULL),(12,2,1,1,'call',2,NULL,NULL),(13,4,1,0,'bet',2,NULL,NULL),(14,1,2,0,'call',4,NULL,NULL),(15,2,2,0,'check',0,NULL,NULL),(16,2,2,1,'call',4,NULL,NULL),(17,4,2,0,'bet',4,NULL,NULL),(18,1,3,0,'fold',0,NULL,NULL),(19,2,3,0,'check',0,NULL,NULL),(20,2,3,1,'fold',0,NULL,NULL),(21,4,3,0,'bet',4,NULL,NULL),(22,8,0,0,'fold',0,NULL,NULL),(23,9,0,0,'call',2,NULL,NULL),(24,10,0,0,'fold',0,NULL,NULL),(25,11,0,0,'blind',1,NULL,NULL),(26,11,0,1,'call',1,NULL,NULL),(27,12,0,0,'blind',2,NULL,NULL),(28,12,0,1,'check',0,NULL,NULL),(29,13,0,0,'fold',0,NULL,NULL),(30,14,0,0,'fold',0,NULL,NULL),(31,9,1,0,'call',2,NULL,NULL),(32,11,1,0,'check',0,NULL,NULL),(33,11,1,1,'call',2,NULL,NULL),(34,12,1,0,'bet',2,NULL,NULL),(35,9,2,0,'bet',8,NULL,NULL),(36,11,2,0,'check',0,NULL,NULL),(37,11,2,1,'fold',0,NULL,NULL),(38,12,2,0,'bet',4,NULL,NULL),(39,12,2,1,'call',4,NULL,NULL),(40,9,3,0,'bet',4,NULL,NULL),(41,12,3,0,'check',0,NULL,NULL),(42,12,3,1,'call',4,NULL,NULL),(43,15,0,0,'fold',0,NULL,NULL),(44,16,0,0,'fold',0,NULL,NULL),(45,17,0,0,'call',2,NULL,NULL),(46,17,0,1,'call',2,NULL,NULL),(47,18,0,0,'call',2,NULL,NULL),(48,18,0,1,'call',2,NULL,NULL),(49,19,0,0,'blind',1,NULL,NULL),(50,19,0,1,'bet',3,NULL,NULL),(51,20,0,0,'blind',2,NULL,NULL),(52,20,0,1,'call',2,NULL,NULL),(53,21,0,0,'fold',0,NULL,NULL),(54,17,1,0,'bet',2,NULL,NULL),(55,17,1,1,'bet',4,NULL,NULL),(56,17,1,2,'call',2,NULL,NULL),(57,18,1,0,'bet',4,NULL,NULL),(58,18,1,1,'bet',4,NULL,NULL),(59,19,1,0,'check',0,NULL,NULL),(60,19,1,1,'fold',0,NULL,NULL),(61,20,1,0,'check',0,NULL,NULL),(62,20,1,1,'fold',0,NULL,NULL),(63,17,2,0,'bet',4,NULL,NULL),(64,17,2,1,'bet',8,NULL,NULL),(65,17,2,2,'call',4,NULL,NULL),(66,18,2,0,'bet',8,NULL,NULL),(67,18,2,1,'bet',8,NULL,NULL),(68,17,3,0,'bet',4,NULL,NULL),(69,17,3,1,'bet',8,NULL,NULL),(70,17,3,2,'call',4,NULL,NULL),(71,18,3,0,'bet',8,NULL,NULL),(72,18,3,1,'bet',8,NULL,NULL),(73,22,3,0,'blind',500,NULL,NULL),(74,22,3,1,'call',1000,NULL,NULL),(75,23,3,0,'fold',0,NULL,NULL),(76,24,3,0,'bet',1500,NULL,NULL),(77,25,3,0,'fold',0,NULL,NULL),(78,22,4,0,'call',1500,NULL,NULL),(79,24,4,0,'bet',1500,NULL,NULL),(80,22,5,0,'call',3000,NULL,NULL),(81,24,5,0,'bet',3000,NULL,NULL),(82,22,6,0,'bet',3000,NULL,NULL),(83,24,6,0,'call',3000,NULL,NULL),(84,22,7,0,'bet',3000,NULL,NULL),(85,24,7,0,'call',3000,NULL,NULL),(86,26,0,0,'blind',100,NULL,NULL),(87,26,0,1,'check',0,NULL,NULL),(88,27,0,0,'fold',0,NULL,NULL),(89,28,0,0,'fold',0,NULL,NULL),(90,29,0,0,'fold',0,NULL,NULL),(91,30,0,0,'fold',0,NULL,NULL),(92,31,0,0,'fold',0,NULL,NULL),(93,32,0,0,'blind',100,NULL,NULL),(94,32,0,1,'check',0,NULL,NULL),(95,33,0,0,'call',100,NULL,NULL),(96,34,0,0,'blind',50,NULL,NULL),(97,34,0,1,'call',50,NULL,NULL),(98,26,1,0,'check',0,NULL,NULL),(99,32,1,0,'check',0,NULL,NULL),(100,33,1,0,'check',0,NULL,NULL),(101,34,1,0,'check',0,NULL,NULL),(102,26,2,0,'check',0,NULL,NULL),(103,26,2,1,'fold',0,NULL,NULL),(104,32,2,0,'check',0,NULL,NULL),(105,32,2,1,'fold',0,NULL,NULL),(106,33,2,0,'bet',400,NULL,NULL),(107,34,2,0,'check',0,NULL,NULL),(108,34,2,1,'call',400,NULL,NULL),(109,33,3,0,'check',0,NULL,NULL),(110,34,3,0,'check',0,NULL,NULL),(111,35,0,0,'blind',50,NULL,NULL),(112,35,0,1,'call',150,NULL,NULL),(113,36,0,0,'blind',100,NULL,NULL),(114,36,0,1,'call',100,NULL,NULL),(115,37,0,0,'fold',0,NULL,NULL),(116,38,0,0,'bet',200,NULL,NULL),(117,39,0,0,'fold',0,NULL,NULL),(118,40,0,0,'call',200,NULL,NULL),(119,41,0,0,'fold',0,NULL,NULL),(120,42,0,0,'fold',0,NULL,NULL),(121,43,0,0,'fold',0,NULL,NULL),(122,35,1,0,'check',0,NULL,NULL),(123,36,1,0,'check',0,NULL,NULL),(124,38,1,0,'check',0,NULL,NULL),(125,40,1,0,'check',0,NULL,NULL),(126,35,2,0,'check',0,NULL,NULL),(127,35,2,1,'fold',0,NULL,NULL),(128,36,2,0,'check',0,NULL,NULL),(129,36,2,1,'call',350,NULL,NULL),(130,38,2,0,'bet',350,NULL,NULL),(131,40,2,0,'fold',0,NULL,NULL),(132,36,3,0,'check',0,NULL,NULL),(133,36,3,1,'call',1000,NULL,NULL),(134,38,3,0,'bet',1000,NULL,NULL),(135,44,0,0,'bet',200,NULL,NULL),(136,44,0,1,'unbet',100,NULL,NULL),(137,45,0,0,'blind',50,NULL,NULL),(138,45,0,1,'fold',0,NULL,NULL),(139,46,0,0,'blind',100,NULL,NULL),(140,46,0,1,'fold',0,NULL,NULL),(141,47,0,0,'fold',0,NULL,NULL),(142,48,0,0,'fold',0,NULL,NULL),(143,49,0,0,'fold',0,NULL,NULL),(144,50,0,0,'fold',0,NULL,NULL),(145,51,0,0,'fold',0,NULL,NULL),(146,52,0,0,'bet',400,NULL,NULL),(147,53,0,0,'fold',0,NULL,NULL),(148,54,0,0,'blind',50,NULL,NULL),(149,54,0,1,'fold',0,NULL,NULL),(150,55,0,0,'blind',100,NULL,NULL),(151,55,0,1,'fold',0,NULL,NULL),(152,56,0,0,'call',100,NULL,NULL),(153,56,0,1,'fold',0,NULL,NULL),(154,57,0,0,'fold',0,NULL,NULL),(155,58,0,0,'call',100,NULL,NULL),(156,58,0,1,'fold',0,NULL,NULL),(157,59,0,0,'call',100,NULL,NULL),(158,59,0,1,'call',300,NULL,NULL),(159,52,1,0,'bet',800,NULL,NULL),(160,52,1,1,'unbet',800,NULL,NULL),(161,59,1,0,'check',0,NULL,NULL),(162,59,1,1,'fold',0,NULL,NULL),(163,60,0,0,'fold',0,NULL,NULL),(164,61,0,0,'fold',0,NULL,NULL),(165,62,0,0,'blind',50,NULL,NULL),(166,62,0,1,'call',50,NULL,NULL),(167,63,0,0,'blind',100,NULL,NULL),(168,63,0,1,'check',0,NULL,NULL),(169,64,0,0,'fold',0,NULL,NULL),(170,65,0,0,'fold',0,NULL,NULL),(171,66,0,0,'call',100,NULL,NULL),(172,67,0,0,'call',100,NULL,NULL),(173,62,1,0,'bet',300,NULL,NULL),(174,62,1,1,'bet',3400,NULL,NULL),(175,62,1,2,'bet',15230,NULL,NULL),(176,63,1,0,'fold',0,NULL,NULL),(177,66,1,0,'fold',0,NULL,NULL),(178,67,1,0,'bet',1100,NULL,NULL),(179,67,1,1,'bet',10400,NULL,NULL),(180,67,1,2,'call',3730,NULL,NULL); +/*!40000 ALTER TABLE `hands_actions` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `hands_players` +-- + +DROP TABLE IF EXISTS `hands_players`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `hands_players` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `hand_id` bigint(20) unsigned default NULL, + `player_id` int(10) unsigned default NULL, + `player_startcash` int(11) default NULL, + `position` char(1) default NULL, + `ante` int(11) default NULL, + `card1_value` smallint(6) default NULL, + `card1_suit` char(1) default NULL, + `card2_value` smallint(6) default NULL, + `card2_suit` char(1) default NULL, + `card3_value` smallint(6) default NULL, + `card3_suit` char(1) default NULL, + `card4_value` smallint(6) default NULL, + `card4_suit` char(1) default NULL, + `card5_value` smallint(6) default NULL, + `card5_suit` char(1) default NULL, + `card6_value` smallint(6) default NULL, + `card6_suit` char(1) default NULL, + `card7_value` smallint(6) default NULL, + `card7_suit` char(1) default NULL, + `winnings` int(11) default NULL, + `rake` int(11) default NULL, + `comment` text, + `comment_ts` datetime default NULL, + `tourneys_players_id` bigint(20) unsigned default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `hand_id` (`hand_id`), + KEY `player_id` (`player_id`), + KEY `tourneys_players_id` (`tourneys_players_id`), + CONSTRAINT `hands_players_ibfk_1` FOREIGN KEY (`hand_id`) REFERENCES `hands` (`id`), + CONSTRAINT `hands_players_ibfk_2` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`), + CONSTRAINT `hands_players_ibfk_3` FOREIGN KEY (`tourneys_players_id`) REFERENCES `tourneys_players` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `hands_players` +-- + +LOCK TABLES `hands_players` WRITE; +/*!40000 ALTER TABLE `hands_players` DISABLE KEYS */; +INSERT INTO `hands_players` VALUES (1,1,1,75,'0',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(2,1,2,59,'S',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(3,1,3,147,'B',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(4,1,4,198,'4',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,31,1,NULL,NULL,NULL),(5,1,5,122,'3',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(6,1,6,48,'2',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(7,1,7,139,'1',NULL,10,'s',11,'h',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(8,2,1,65,'2',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(9,2,2,49,'1',NULL,8,'s',9,'s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,35,1,NULL,NULL,NULL),(10,2,3,179,'0',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(11,2,4,205,'S',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(12,2,5,118,'B',NULL,12,'h',11,'s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(13,2,6,34,'4',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(14,2,7,135,'3',NULL,8,'d',5,'d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(15,3,1,65,'3',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(16,3,2,68,'2',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(17,3,3,179,'1',NULL,14,'h',9,'d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,92,4,NULL,NULL,NULL),(18,3,4,201,'0',NULL,14,'c',10,'d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(19,3,5,102,'S',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(20,3,6,34,'B',NULL,0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(21,3,7,135,'4',NULL,7,'c',11,'h',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(22,4,8,30350,NULL,300,5,'c',4,'h',2,'s',6,'c',14,'c',2,'c',2,'h',25000,200,NULL,NULL,NULL),(23,4,9,16400,NULL,300,0,'x',0,'x',3,'c',0,'x',0,'x',0,'x',0,'x',0,0,NULL,NULL,NULL),(24,4,10,91250,NULL,300,0,'x',0,'x',8,'c',5,'h',14,'h',11,'d',0,'x',0,0,NULL,NULL,NULL),(25,4,11,53150,NULL,300,0,'x',0,'x',11,'c',0,'x',0,'x',0,'x',0,'x',0,0,NULL,NULL,NULL),(26,5,12,9490,'B',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(27,5,13,14700,'6',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(28,5,14,6280,'5',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(29,5,15,13655,'4',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(30,5,16,5605,'3',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(31,5,17,25295,'2',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(32,5,18,20000,'1',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(33,5,19,16250,'0',NULL,10,'d',5,'s',3,'d',11,'s',NULL,NULL,NULL,NULL,NULL,NULL,1140,60,NULL,NULL,NULL),(34,5,20,27070,'S',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(35,6,12,9390,'S',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(36,6,21,10000,'B',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(37,6,14,6280,'6',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(38,6,15,13655,'5',NULL,4,'s',10,'c',14,'s',14,'c',NULL,NULL,NULL,NULL,NULL,NULL,3325,175,NULL,NULL,NULL),(39,6,16,5605,'4',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(40,6,17,25295,'3',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(41,6,18,19900,'2',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(42,6,19,16890,'1',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(43,6,20,26570,'0',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(44,7,12,9190,'0',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,250,0,NULL,NULL,NULL),(45,7,21,8450,'S',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(46,7,14,6280,'B',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(47,7,15,15430,'5',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(48,7,17,25095,'4',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(49,7,18,19900,'3',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(50,7,19,16890,'2',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(51,7,20,26570,'1',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(52,8,12,9340,'1',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,1095,55,NULL,NULL,NULL),(53,8,21,8400,'0',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(54,8,14,6180,'S',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(55,8,15,15430,'B',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(56,8,17,25095,'5',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(57,8,18,19900,'4',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(58,8,19,16890,'3',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(59,8,20,26570,'2',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(60,9,12,10035,'1',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(61,9,14,6130,'0',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(62,9,15,15330,'S',NULL,11,'c',11,'h',7,'s',5,'h',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(63,9,22,5000,'B',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(64,9,17,24995,'5',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(65,9,18,19900,'4',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(66,9,19,16790,'3',NULL,0,'x',0,'x',0,'x',0,'x',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL,NULL),(67,9,20,26170,'2',NULL,13,'h',14,'d',6,'h',12,'d',NULL,NULL,NULL,NULL,NULL,NULL,30560,300,NULL,NULL,NULL); +/*!40000 ALTER TABLE `hands_players` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `players` +-- + +DROP TABLE IF EXISTS `players`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `players` ( + `id` int(10) unsigned NOT NULL auto_increment, + `name` varchar(32) default NULL, + `site_id` smallint(5) unsigned default NULL, + `comment` text, + `comment_ts` datetime default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `site_id` (`site_id`), + CONSTRAINT `players_ibfk_1` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `players` +-- + +LOCK TABLES `players` WRITE; +/*!40000 ALTER TABLE `players` DISABLE KEYS */; +INSERT INTO `players` VALUES (1,'Player_1',2,NULL,NULL),(2,'Player_2',2,NULL,NULL),(3,'Player_3',2,NULL,NULL),(4,'Player_4',2,NULL,NULL),(5,'Player_5',2,NULL,NULL),(6,'Player_6',2,NULL,NULL),(7,'Player_7',2,NULL,NULL),(8,'Play er9',1,NULL,NULL),(9,'Player_11',1,NULL,NULL),(10,'Player13',1,NULL,NULL),(11,'Player15',1,NULL,NULL),(12,'player16',1,NULL,NULL),(13,'player25',1,NULL,NULL),(14,'player18',1,NULL,NULL),(15,'player19',1,NULL,NULL),(16,'play-er26',1,NULL,NULL),(17,'player21',1,NULL,NULL),(18,'player22',1,NULL,NULL),(19,'player23',1,NULL,NULL),(20,'player24',1,NULL,NULL),(21,'player17',1,NULL,NULL),(22,'player20',1,NULL,NULL); +/*!40000 ALTER TABLE `players` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `sites` +-- + +DROP TABLE IF EXISTS `sites`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `sites` ( + `id` smallint(5) unsigned NOT NULL auto_increment, + `name` varchar(32) default NULL, + `currency` char(3) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `sites` +-- + +LOCK TABLES `sites` WRITE; +/*!40000 ALTER TABLE `sites` DISABLE KEYS */; +INSERT INTO `sites` VALUES (1,'Full Tilt Poker','USD'),(2,'PokerStars','USD'); +/*!40000 ALTER TABLE `sites` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `tourneys` +-- + +DROP TABLE IF EXISTS `tourneys`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `tourneys` ( + `id` int(10) unsigned NOT NULL auto_increment, + `gametype_id` smallint(5) unsigned default NULL, + `site_tourney_no` bigint(20) default NULL, + `buyin` int(11) default NULL, + `fee` int(11) default NULL, + `knockout` int(11) default NULL, + `entries` int(11) default NULL, + `prizepool` int(11) default NULL, + `start_time` datetime default NULL, + `comment` text, + `comment_ts` datetime default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `gametype_id` (`gametype_id`), + CONSTRAINT `tourneys_ibfk_1` FOREIGN KEY (`gametype_id`) REFERENCES `gametypes` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `tourneys` +-- + +LOCK TABLES `tourneys` WRITE; +/*!40000 ALTER TABLE `tourneys` DISABLE KEYS */; +/*!40000 ALTER TABLE `tourneys` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `tourneys_players` +-- + +DROP TABLE IF EXISTS `tourneys_players`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `tourneys_players` ( + `id` bigint(20) unsigned NOT NULL auto_increment, + `tourney_id` int(10) unsigned default NULL, + `player_id` int(10) unsigned default NULL, + `payin_amount` int(11) default NULL, + `rank` int(11) default NULL, + `winnings` int(11) default NULL, + `comment` text, + `comment_ts` datetime default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`), + KEY `tourney_id` (`tourney_id`), + KEY `player_id` (`player_id`), + CONSTRAINT `tourneys_players_ibfk_1` FOREIGN KEY (`tourney_id`) REFERENCES `tourneys` (`id`), + CONSTRAINT `tourneys_players_ibfk_2` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `tourneys_players` +-- + +LOCK TABLES `tourneys_players` WRITE; +/*!40000 ALTER TABLE `tourneys_players` DISABLE KEYS */; +/*!40000 ALTER TABLE `tourneys_players` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2008-07-12 18:42:27 diff --git a/regression-test/ps-flags-B-1hands.expected.txt b/regression-test/ps-flags-B-1hands.expected.txt new file mode 100644 index 00000000..fc3d1642 --- /dev/null +++ b/regression-test/ps-flags-B-1hands.expected.txt @@ -0,0 +1,68 @@ +Connected to MySQL on localhost. Print Player Flags Utility + +Basic Data +========== +bigBet: 4 category: holdem limitType: fl name: Player_5 gameType: ring site: PokerStars +siteId: 2 gametypeId: 1 playerId: 5 hudDataId: 12 + +HUD Raw Hand Counts +=================== +HDs: 1 +street0VPI: 0 +street0Aggr: 0 +street0_3B4BChance: 0 +street0_3B4BDone: 0 + +street1Seen: 1 +street2Seen: 1 +street3Seen: 1 +street4Seen: 0 +sawShowdown: 1 + +street1Aggr: 1 +street2Aggr: 1 +street3Aggr: 0 +street4Aggr: 0 + +otherRaisedStreet1: 0 +otherRaisedStreet2: 1 +otherRaisedStreet3: 1 +otherRaisedStreet4: 0 +foldToOtherRaisedStreet1: 0 +foldToOtherRaisedStreet2: 0 +foldToOtherRaisedStreet3: 0 +foldToOtherRaisedStreet4: 0 + +wonWhenSeenStreet1: 0.0 +wonAtSD: 0.0 +stealAttemptChance: 0 +stealAttempted: 0 +foldBbToStealChance: 0 +foldedBbToSteal: 0 +foldSbToStealChance: 0 +foldedSbToSteal: 0 +street1CBChance: 0 +street1CBDone: 0 +street2CBChance: 0 +street2CBDone: 0 +street3CBChance: 0 +street3CBDone: 0 +street4CBChance: 0 +street4CBDone: 0 +foldToStreet1CBChance: 0 +foldToStreet1CBDone: 0 +foldToStreet2CBChance: 0 +foldToStreet2CBDone: 0 +foldToStreet3CBChance: 0 +foldToStreet3CBDone: 0 +foldToStreet4CBChance: 0 +foldToStreet4CBDone: 0 +totalProfit: +street1CheckCallRaiseChance: +street1CheckCallRaiseDone: +street2CheckCallRaiseChance: +street2CheckCallRaiseDone: +street3CheckCallRaiseChance: +street3CheckCallRaiseDone: +street4CheckCallRaiseChance: 0 +street4CheckCallRaiseDone: 0 diff --git a/regression-test/ps-flags-CBflop.expected.txt b/regression-test/ps-flags-CBflop.expected.txt new file mode 100644 index 00000000..a7f9469f --- /dev/null +++ b/regression-test/ps-flags-CBflop.expected.txt @@ -0,0 +1,68 @@ +Connected to MySQL on localhost. Print Player Flags Utility + +Basic Data +========== +bigBet: 50 category: holdem limitType: fl name: player3 gameType: ring site: PokerStars +siteId: 2 gametypeId: 2 playerId: 11 hudDataId: 22 + +HUD Raw Hand Counts +=================== +HDs: 1 +street0VPI: 1 +street0Aggr: 1 +street0_3B4BChance: 1 +street0_3B4BDone: 1 + +street1Seen: 1 +street2Seen: 1 +street3Seen: 1 +street4Seen: 0 +sawShowdown: 1 + +street1Aggr: 1 +street2Aggr: 0 +street3Aggr: 0 +street4Aggr: 0 + +otherRaisedStreet1: 0 +otherRaisedStreet2: +otherRaisedStreet3: +otherRaisedStreet4: 0 +foldToOtherRaisedStreet1: 0 +foldToOtherRaisedStreet2: 0 +foldToOtherRaisedStreet3: 0 +foldToOtherRaisedStreet4: 0 + +wonWhenSeenStreet1: 0.0 +wonAtSD: 0.0 +stealAttemptChance: 0 +stealAttempted: 0 +foldBbToStealChance: 0 +foldedBbToSteal: 0 +foldSbToStealChance: 0 +foldedSbToSteal: 0 +street1CBChance: 1 +street1CBDone: 1 +street2CBChance: 0 +street2CBDone: 0 +street3CBChance: 0 +street3CBDone: 0 +street4CBChance: 0 +street4CBDone: 0 +foldToStreet1CBChance: 0 +foldToStreet1CBDone: 0 +foldToStreet2CBChance: 0 +foldToStreet2CBDone: 0 +foldToStreet3CBChance: 0 +foldToStreet3CBDone: 0 +foldToStreet4CBChance: 0 +foldToStreet4CBDone: 0 +totalProfit: +street1CheckCallRaiseChance: 0 +street1CheckCallRaiseDone: 0 +street2CheckCallRaiseChance: 0 +street2CheckCallRaiseDone: 0 +street3CheckCallRaiseChance: 0 +street3CheckCallRaiseDone: 0 +street4CheckCallRaiseChance: 0 +street4CheckCallRaiseDone: 0 diff --git a/regression-test/ps-flags-M-2hands.expected.txt b/regression-test/ps-flags-M-2hands.expected.txt new file mode 100644 index 00000000..1169e488 --- /dev/null +++ b/regression-test/ps-flags-M-2hands.expected.txt @@ -0,0 +1,68 @@ +Connected to MySQL on localhost. Print Player Flags Utility + +Basic Data +========== +bigBet: 4 category: holdem limitType: fl name: Player_1 gameType: ring site: PokerStars +siteId: 2 gametypeId: 1 playerId: 1 hudDataId: 8 + +HUD Raw Hand Counts +=================== +HDs: 2 +street0VPI: 0 +street0Aggr: 0 +street0_3B4BChance: 0 +street0_3B4BDone: 0 + +street1Seen: 0 +street2Seen: 0 +street3Seen: 0 +street4Seen: 0 +sawShowdown: 0 + +street1Aggr: 0 +street2Aggr: 0 +street3Aggr: 0 +street4Aggr: 0 + +otherRaisedStreet1: 0 +otherRaisedStreet2: 0 +otherRaisedStreet3: 0 +otherRaisedStreet4: 0 +foldToOtherRaisedStreet1: 0 +foldToOtherRaisedStreet2: 0 +foldToOtherRaisedStreet3: 0 +foldToOtherRaisedStreet4: 0 + +wonWhenSeenStreet1: 0.0 +wonAtSD: 0.0 +stealAttemptChance: 0 +stealAttempted: 0 +foldBbToStealChance: 0 +foldedBbToSteal: 0 +foldSbToStealChance: 0 +foldedSbToSteal: 0 +street1CBChance: 0 +street1CBDone: 0 +street2CBChance: 0 +street2CBDone: 0 +street3CBChance: 0 +street3CBDone: 0 +street4CBChance: 0 +street4CBDone: 0 +foldToStreet1CBChance: 0 +foldToStreet1CBDone: 0 +foldToStreet2CBChance: 0 +foldToStreet2CBDone: 0 +foldToStreet3CBChance: 0 +foldToStreet3CBDone: 0 +foldToStreet4CBChance: 0 +foldToStreet4CBDone: 0 +totalProfit: 0 +street1CheckCallRaiseChance: 0 +street1CheckCallRaiseDone: 0 +street2CheckCallRaiseChance: 0 +street2CheckCallRaiseDone: 0 +street3CheckCallRaiseChance: 0 +street3CheckCallRaiseDone: 0 +street4CheckCallRaiseChance: 0 +street4CheckCallRaiseDone: 0 diff --git a/regression-test/ps-flags-studhilo.expected.txt b/regression-test/ps-flags-studhilo.expected.txt new file mode 100644 index 00000000..11839d76 --- /dev/null +++ b/regression-test/ps-flags-studhilo.expected.txt @@ -0,0 +1,68 @@ +Connected to MySQL on localhost. Print Player Flags Utility + +Basic Data +========== +bigBet: 20 category: studhilo limitType: fl name: br1an gameType: ring site: PokerStars +siteId: 2 gametypeId: 3 playerId: 21 hudDataId: 32 + +HUD Raw Hand Counts +=================== +HDs: 1 +street0VPI: 0 +street0Aggr: 0 +street0_3B4BChance: 0 +street0_3B4BDone: 0 + +street1Seen: 1 +street2Seen: 1 +street3Seen: 1 +street4Seen: 1 +sawShowdown: 1 + +street1Aggr: 0 +street2Aggr: 0 +street3Aggr: 0 +street4Aggr: 0 + +otherRaisedStreet1: 0 +otherRaisedStreet2: 1 +otherRaisedStreet3: 0 +otherRaisedStreet4: 1 +foldToOtherRaisedStreet1: 0 +foldToOtherRaisedStreet2: 0 +foldToOtherRaisedStreet3: 0 +foldToOtherRaisedStreet4: 0 + +wonWhenSeenStreet1: 0.0 +wonAtSD: 0.0 +stealAttemptChance: 0 +stealAttempted: 0 +foldBbToStealChance: 0 +foldedBbToSteal: 0 +foldSbToStealChance: 0 +foldedSbToSteal: 0 +street1CBChance: 0 +street1CBDone: 0 +street2CBChance: 0 +street2CBDone: 0 +street3CBChance: 0 +street3CBDone: 0 +street4CBChance: 0 +street4CBDone: 0 +foldToStreet1CBChance: 0 +foldToStreet1CBDone: 0 +foldToStreet2CBChance: 0 +foldToStreet2CBDone: 0 +foldToStreet3CBChance: 0 +foldToStreet3CBDone: 0 +foldToStreet4CBChance: 0 +foldToStreet4CBDone: 0 +totalProfit: -0.47 +street1CheckCallRaiseChance: 0 +street1CheckCallRaiseDone: 0 +street2CheckCallRaiseChance: 0 +street2CheckCallRaiseDone: 0 +street3CheckCallRaiseChance: 0 +street3CheckCallRaiseDone: 0 +street4CheckCallRaiseChance: 1 +street4CheckCallRaiseDone: 0 diff --git a/regression-test/ps-lhe-ring-3hands.txt b/regression-test/ps-lhe-ring-3hands.txt new file mode 100644 index 00000000..9afd29ef --- /dev/null +++ b/regression-test/ps-lhe-ring-3hands.txt @@ -0,0 +1,169 @@ +PokerStars Game #14519394979: Hold'em Limit ($0.02/$0.04) - 2008/01/13 - 00:22:15 (ET) +Table 'Merope' 10-max Seat #1 is the button +Seat 1: Player_1 ($0.75 in chips) +Seat 3: Player_2 ($0.59 in chips) +Seat 4: Player_3 ($1.47 in chips) +Seat 6: Player_4 ($1.98 in chips) +Seat 7: Player_5 ($1.22 in chips) +Seat 8: Player_6 ($0.48 in chips) +Seat 9: Player_7 ($1.39 in chips) +Player_2: posts small blind $0.01 +Player_3: posts big blind $0.02 +*** HOLE CARDS *** +Dealt to Player_7 [Ts Jh] +Player_4: raises $0.02 to $0.04 +Player_5: folds +Player_6: folds +Player_7: folds +Player_1: calls $0.04 +Player_2: calls $0.03 +Player_3: folds +*** FLOP *** [Qd Th Js] +Player_2: checks +Player_4: bets $0.02 +Player_1: calls $0.02 +Player_2: calls $0.02 +*** TURN *** [Qd Th Js] [2s] +Player_2: checks +Player_4: bets $0.04 +Player_1: calls $0.04 +Player_2: calls $0.04 +*** RIVER *** [Qd Th Js 2s] [7s] +Player_2: checks +Player_4: bets $0.04 +Player_1: folds +Player_2: folds +Player_4 collected $0.31 from pot +*** SUMMARY *** +Total pot $0.32 | Rake $0.01 +Board [Qd Th Js 2s 7s] +Seat 1: Player_1 (button) folded on the River +Seat 3: Player_2 (small blind) folded on the River +Seat 4: Player_3 (big blind) folded before Flop +Seat 6: Player_4 collected ($0.31) +Seat 7: Player_5 folded before Flop (didn't bet) +Seat 8: Player_6 folded before Flop (didn't bet) +Seat 9: Player_7 folded before Flop (didn't bet) + + + +PokerStars Game #14519420999: Hold'em Limit ($0.02/$0.04) - 2008/01/13 - 00:23:43 (ET) +Table 'Merope' 10-max Seat #4 is the button +Seat 1: Player_1 ($0.65 in chips) +Seat 3: Player_2 ($0.49 in chips) +Seat 4: Player_3 ($1.79 in chips) +Seat 6: Player_4 ($2.05 in chips) +Seat 7: Player_5 ($1.18 in chips) +Seat 8: Player_6 ($0.34 in chips) +Seat 9: Player_7 ($1.35 in chips) +wakked13 will be allowed to play after the button +Player_4: posts small blind $0.01 +Player_5: posts big blind $0.02 +*** HOLE CARDS *** +Dealt to Player_7 [8d 5d] +Player_6 said, "vn" +Player_6: folds +Player_7: folds +Player_1: folds +Player_2: calls $0.02 +Player_3: folds +Player_4: calls $0.01 +Player_5: checks +*** FLOP *** [Th Jd 3c] +Player_3 said, "ty" +Player_4: checks +Player_5: bets $0.02 +Player_2: calls $0.02 +Player_4: calls $0.02 +*** TURN *** [Th Jd 3c] [7c] +Player_4: checks +Player_5: bets $0.04 +Player_2: raises $0.04 to $0.08 +Player_4: folds +Player_5: calls $0.04 +*** RIVER *** [Th Jd 3c 7c] [4s] +Player_5: checks +Player_2: bets $0.04 +Player_5: calls $0.04 +*** SHOW DOWN *** +Player_2: shows [8s 9s] (a straight, Seven to Jack) +Player_5: mucks hand +Player_2 collected $0.35 from pot +*** SUMMARY *** +Total pot $0.36 | Rake $0.01 +Board [Th Jd 3c 7c 4s] +Seat 1: Player_1 folded before Flop (didn't bet) +Seat 3: Player_2 showed [8s 9s] and won ($0.35) with a straight, Seven to Jack +Seat 4: Player_3 (button) folded before Flop (didn't bet) +Seat 6: Player_4 (small blind) folded on the Turn +Seat 7: Player_5 (big blind) mucked [Qh Js] +Seat 8: Player_6 folded before Flop (didn't bet) +Seat 9: Player_7 folded before Flop (didn't bet) + + + +PokerStars Game #14519433154: Hold'em Limit ($0.02/$0.04) - 2008/01/13 - 00:24:25 (ET) +Table 'Merope' 10-max Seat #6 is the button +Seat 1: Player_1 ($0.65 in chips) +Seat 3: Player_2 ($0.68 in chips) +Seat 4: Player_3 ($1.79 in chips) +Seat 6: Player_4 ($2.01 in chips) +Seat 7: Player_5 ($1.02 in chips) +Seat 8: Player_6 ($0.34 in chips) +Seat 9: Player_7 ($1.35 in chips) +Player_5: posts small blind $0.01 +Player_6: posts big blind $0.02 +wakked13: sits out +*** HOLE CARDS *** +Dealt to Player_7 [7c Jh] +Player_7: folds +Player_1: folds +Player_2: folds +Player_3: calls $0.02 +Player_4: calls $0.02 +Player_5: raises $0.02 to $0.04 +Player_6: calls $0.02 +Player_3: calls $0.02 +Player_4: calls $0.02 +*** FLOP *** [4h 9s Ad] +Player_5: checks +Player_6: checks +Player_3: bets $0.02 +Player_4: raises $0.02 to $0.04 +Player_5: folds +Player_6: folds +Player_3: raises $0.02 to $0.06 +Player_4: raises $0.02 to $0.08 +Betting is capped +Player_3: calls $0.02 +*** TURN *** [4h 9s Ad] [Qc] +Player_3: bets $0.04 +Player_4: raises $0.04 to $0.08 +Player_3: raises $0.04 to $0.12 +Player_4: raises $0.04 to $0.16 +Betting is capped +Player_3: calls $0.04 +*** RIVER *** [4h 9s Ad Qc] [Ks] +Player_3: bets $0.04 +Player_4: raises $0.04 to $0.08 +Player_3: raises $0.04 to $0.12 +Player_4: raises $0.04 to $0.16 +Betting is capped +Player_3: calls $0.04 +*** SHOW DOWN *** +Player_4: shows [Ac Td] (a pair of Aces) +Player_3: shows [Ah 9d] (two pair, Aces and Nines) +Player_3 collected $0.92 from pot +*** SUMMARY *** +Total pot $0.96 | Rake $0.04 +Board [4h 9s Ad Qc Ks] +Seat 1: Player_1 folded before Flop (didn't bet) +Seat 3: Player_2 folded before Flop (didn't bet) +Seat 4: Player_3 showed [Ah 9d] and won ($0.92) with two pair, Aces and Nines +Seat 6: Player_4 (button) showed [Ac Td] and lost with a pair of Aces +Seat 7: Player_5 (small blind) folded on the Flop +Seat 8: Player_6 (big blind) folded on the Flop +Seat 9: Player_7 folded before Flop (didn't bet) + + + diff --git a/regression-test/ps-lhe-ring-call-3B-preflop-cb-no2b.txt b/regression-test/ps-lhe-ring-call-3B-preflop-cb-no2b.txt new file mode 100644 index 00000000..797839a9 --- /dev/null +++ b/regression-test/ps-lhe-ring-call-3B-preflop-cb-no2b.txt @@ -0,0 +1,62 @@ +PokerStars Game #19546605871: Hold'em Limit ($0.25/$0.50) - 2008/08/11 - 20:15:41 (ET) +Table 'Pyxis' 10-max Seat #1 is the button +Seat 1: player10 ($7.75 in chips) +Seat 2: player1 ($11.55 in chips) +Seat 3: player2 ($8.25 in chips) +Seat 4: player3 ($0.90 in chips) +Seat 5: player4 ($10003.50 in chips) +Seat 6: player5 ($13.50 in chips) +Seat 7: player6 ($8 in chips) +Seat 8: player7 ($11.80 in chips) +Seat 9: player8 ($11.05 in chips) +Seat 10: player9 ($11.85 in chips) +player1: posts small blind $0.10 +player1 said, "little holy water on the river lol" +player2: posts big blind $0.25 +*** HOLE CARDS *** +Dealt to player6 [Ad Ts] +player3: calls $0.25 +player4: folds +player5: raises $0.25 to $0.50 +player6: calls $0.50 +player7: folds +player8: folds +player9: folds +player10: folds +player1: folds +player2: folds +player3: raises $0.25 to $0.75 +player5: calls $0.25 +player6: calls $0.25 +*** FLOP *** [Js 5d 4c] +player3: bets $0.15 and is all-in +player5: calls $0.15 +player6: calls $0.15 +*** TURN *** [Js 5d 4c] [4s] +player5: bets $0.50 +player6: calls $0.50 +*** RIVER *** [Js 5d 4c 4s] [6d] +player5: bets $0.50 +player6: calls $0.50 +*** SHOW DOWN *** +player5: shows [Qc Ac] (a pair of Fours) +player6: mucks hand +player5 collected $1.90 from side pot +player3: shows [9c 7c] (a pair of Fours - lower kicker) +player5 collected $2.95 from main pot +*** SUMMARY *** +Total pot $5.05 Main pot $2.95. Side pot $1.90. | Rake $0.20 +Board [Js 5d 4c 4s 6d] +Seat 1: player10 (button) folded before Flop (didn't bet) +Seat 2: player1 (small blind) folded before Flop +Seat 3: player2 (big blind) folded before Flop +Seat 4: player3 showed [9c 7c] and lost with a pair of Fours +Seat 5: player4 folded before Flop (didn't bet) +Seat 6: player5 showed [Qc Ac] and won ($4.85) with a pair of Fours +Seat 7: player6 mucked [Ad Ts] +Seat 8: player7 folded before Flop (didn't bet) +Seat 9: player8 folded before Flop (didn't bet) +Seat 10: player9 folded before Flop (didn't bet) + + + diff --git a/regression-test/ps-lhe-ring-successful-steal-by-cutoff.txt b/regression-test/ps-lhe-ring-successful-steal-by-cutoff.txt new file mode 100644 index 00000000..3d402cef --- /dev/null +++ b/regression-test/ps-lhe-ring-successful-steal-by-cutoff.txt @@ -0,0 +1,42 @@ +PokerStars Game #19546637866: Hold'em Limit ($0.25/$0.50) - 2008/08/11 - 20:17:04 (ET) +Table 'Pyxis' 10-max Seat #2 is the button +Seat 1: player1 ($7.75 in chips) +Seat 2: player2 ($11.45 in chips) +Seat 5: player3 ($10003.50 in chips) +Seat 6: player4 ($16.45 in chips) +Seat 7: player5 ($6.10 in chips) +Seat 8: player6 ($11.80 in chips) +Seat 9: player7 ($11.05 in chips) +Seat 10: player8 ($11.85 in chips) +player9 leaves the table +player10: is sitting out +player10 leaves the table +player3: posts small blind $0.10 +player4: posts big blind $0.25 +*** HOLE CARDS *** +Dealt to player5 [Jh 5d] +Mac Fun K joins the table at seat #4 +player5: folds +player6: folds +player7: folds +player8: folds +player1: raises $0.25 to $0.50 +player2: folds +player3: folds +player4: folds +Uncalled bet ($0.25) returned to player1 +player1 collected $0.60 from pot +player1: doesn't show hand +*** SUMMARY *** +Total pot $0.60 | Rake $0 +Seat 1: player1 collected ($0.60) +Seat 2: player2 (button) folded before Flop (didn't bet) +Seat 5: player3 (small blind) folded before Flop +Seat 6: player4 (big blind) folded before Flop +Seat 7: player5 folded before Flop (didn't bet) +Seat 8: player6 folded before Flop (didn't bet) +Seat 9: player7 folded before Flop (didn't bet) +Seat 10: player8 folded before Flop (didn't bet) + + + diff --git a/regression-test/ps-studhilo-ring-showdown.txt b/regression-test/ps-studhilo-ring-showdown.txt new file mode 100644 index 00000000..ff1276e8 --- /dev/null +++ b/regression-test/ps-studhilo-ring-showdown.txt @@ -0,0 +1,130 @@ +PokerStars Game #15043388146: 7 Card Stud Hi/Lo Limit ($0.10/$0.20) - 2008/02/03 - 22:04:15 (ET) +Table 'Lydia' 8-max +Seat 2: olimpicon99 ($5.31 in chips) +Seat 4: PokerPig55 ($1.58 in chips) +Seat 5: VISTA GIRL ($0.83 in chips) +Seat 6: br1an ($5.10 in chips) +Seat 7: steffen780 ($4 in chips) +Seat 8: willowdale ($3.92 in chips) +olimpicon99: posts the ante $0.02 +PokerPig55: posts the ante $0.02 +VISTA GIRL: posts the ante $0.02 +br1an: posts the ante $0.02 +steffen780: posts the ante $0.02 +willowdale: posts the ante $0.02 +*** 3rd STREET *** +Dealt to olimpicon99 [8c] +Dealt to PokerPig55 [Kh] +Dealt to VISTA GIRL [8h] +Dealt to br1an [2d] +Dealt to steffen780 [Kc 9h 9c] +Dealt to willowdale [5s] +br1an: brings in for $0.05 +steffen780: calls $0.05 +willowdale: calls $0.05 +olimpicon99: folds +olimpicon99 leaves the table +PokerPig55: folds +VISTA GIRL: folds +*** 4th STREET *** +Dealt to br1an [2d] [Qh] +Dealt to steffen780 [Kc 9h 9c] [5c] +Dealt to willowdale [5s] [4s] +br1an: checks +steffen780: checks +willowdale: checks +*** 5th STREET *** +Dealt to br1an [2d Qh] [6d] +Dealt to steffen780 [Kc 9h 9c 5c] [8s] +Dealt to willowdale [5s 4s] [Ad] +willowdale: bets $0.20 +br1an: calls $0.20 +steffen780: folds +*** 6th STREET *** +Dealt to br1an [2d Qh 6d] [6h] +Dealt to willowdale [5s 4s Ad] [5h] +br1an: checks +willowdale: checks +*** RIVER *** +br1an: checks +willowdale: bets $0.20 +br1an: calls $0.20 +*** SHOW DOWN *** +willowdale: shows [3s 4d 5s 4s Ad 5h 2c] (HI: a straight, Ace to Five; LO: 5,4,3,2,A) +br1an: shows [4c 7d 2d Qh 6d 6h 2h] (HI: two pair, Sixes and Deuces) +willowdale collected $0.51 from pot +willowdale collected $0.51 from pot +*** SUMMARY *** +Total pot $1.07 | Rake $0.05 +Seat 2: olimpicon99 folded on the 3rd Street (didn't bet) +Seat 4: PokerPig55 folded on the 3rd Street (didn't bet) +Seat 5: VISTA GIRL folded on the 3rd Street (didn't bet) +Seat 6: br1an showed [4c 7d 2d Qh 6d 6h 2h] and lost with HI: two pair, Sixes and Deuces +Seat 7: steffen780 folded on the 5th Street +Seat 8: willowdale showed [3s 4d 5s 4s Ad 5h 2c] and won ($1.02) with HI: a straight, Ace to Five; LO: 5,4,3,2,A + + + +PokerStars Game #20711747191: Razz Limit ($1/$2) - 2008/09/26 14:36:50 ET +Table 'Siwa III' 8-max +Seat 2: dainmat ($63.15 in chips) +Seat 3: fnJ's ($30.75 in chips) +Seat 4: ambythegreat ($24.90 in chips) +Seat 5: jt studd ($39.90 in chips) +Seat 6: KyleHruby ($11.55 in chips) +Seat 7: nutOmatic ($71.30 in chips) +dainmat: posts the ante $0.10 +fnJ's: posts the ante $0.10 +ambythegreat: posts the ante $0.10 +jt studd: posts the ante $0.10 +KyleHruby: posts the ante $0.10 +nutOmatic: posts the ante $0.10 +*** 3rd STREET *** +Dealt to dainmat [Ts] +Dealt to fnJ's [3s] +Dealt to ambythegreat [5h] +Dealt to jt studd [Ad] +Dealt to KyleHruby [As] +Dealt to nutOmatic [6d Kd Th] +dainmat: brings in for $0.50 +fnJ's: calls $0.50 +ambythegreat: raises $0.50 to $1 +garnishgut joins the table at seat #1 +jt studd: folds +KyleHruby: folds +nutOmatic: folds +dainmat: folds +fnJ's: calls $0.50 +*** 4th STREET *** +Dealt to fnJ's [3s] [6h] +Dealt to ambythegreat [5h] [4c] +ambythegreat: bets $1 +fnJ's: calls $1 +*** 5th STREET *** +Dealt to fnJ's [3s 6h] [2h] +Dealt to ambythegreat [5h 4c] [Kh] +fnJ's: bets $2 +ambythegreat: calls $2 +*** 6th STREET *** +Dealt to fnJ's [3s 6h 2h] [2c] +Dealt to ambythegreat [5h 4c Kh] [5s] +fnJ's: bets $2 +ambythegreat: calls $2 +*** RIVER *** +fnJ's: bets $2 +ambythegreat: calls $2 +*** SHOW DOWN *** +fnJ's: shows [9d 5c 3s 6h 2h 2c 4h] (Lo: 6,5,4,3,2) +ambythegreat: mucks hand +fnJ's collected $16.35 from pot +*** SUMMARY *** +Total pot $17.10 | Rake $0.75 +Seat 2: dainmat folded on the 3rd Street +Seat 3: fnJ's showed [9d 5c 3s 6h 2h 2c 4h] and won ($16.35) with Lo: 6,5,4,3,2 +Seat 4: ambythegreat mucked [6s 7h 5h 4c Kh 5s Jc] +Seat 5: jt studd folded on the 3rd Street (didn't bet) +Seat 6: KyleHruby folded on the 3rd Street (didn't bet) +Seat 7: nutOmatic folded on the 3rd Street (didn't bet) + + + diff --git a/regression-test/ps.14519394979.expected.txt b/regression-test/ps.14519394979.expected.txt new file mode 100644 index 00000000..c1eb98d7 --- /dev/null +++ b/regression-test/ps.14519394979.expected.txt @@ -0,0 +1,49 @@ +Connected to MySQL on localhost. Print Hand Utility +options.site: PokerStars siteId: 2 + +From Table Hands +================ +handId: 1 tableName: Merope siteHandNo: 14519394979 gametypeId: 1 handStart: 2008-01-13 05:22:15 seats: 7 maxSeats: 10 + +From Table Gametypes +==================== +type: ring base: hold category: holdem limitType: fl hiLo: h +sb: 1 bb: 2 sbet: 2 bbet: 4 + +From Table BoardCards +===================== +Board cards: Qd Th Js 2s 7s + +From Table HandsPlayers +======================= +playerName:Player_1 playerStartcash:75 position:Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_2 playerStartcash:59 position:SB cards:?? ?? winnings:0 rake:0 +playerName:Player_3 playerStartcash:147 position:BB cards:?? ?? winnings:0 rake:0 +playerName:Player_4 playerStartcash:198 position:4 off Btn cards:?? ?? winnings:31 rake:1 +playerName:Player_5 playerStartcash:122 position:3 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_6 playerStartcash:48 position:2 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_7 playerStartcash:139 position:1 off Btn cards:Ts Jh winnings:0 rake:0 + +From Table HandsActions +======================= +playerName:Player_1 street:Preflop streetActionNo:6 action:call amount:4 +playerName:Player_1 street:Flop streetActionNo:2 action:call amount:2 +playerName:Player_1 street:Turn streetActionNo:2 action:call amount:4 +playerName:Player_1 street:River streetActionNo:2 action:fold amount:0 +playerName:Player_2 street:Preflop streetActionNo:0 action:blind amount:1 +playerName:Player_2 street:Preflop streetActionNo:7 action:call amount:3 +playerName:Player_2 street:Flop streetActionNo:0 action:check amount:0 +playerName:Player_2 street:Flop streetActionNo:3 action:call amount:2 +playerName:Player_2 street:Turn streetActionNo:0 action:check amount:0 +playerName:Player_2 street:Turn streetActionNo:3 action:call amount:4 +playerName:Player_2 street:River streetActionNo:0 action:check amount:0 +playerName:Player_2 street:River streetActionNo:3 action:fold amount:0 +playerName:Player_3 street:Preflop streetActionNo:1 action:blind amount:2 +playerName:Player_3 street:Preflop streetActionNo:8 action:fold amount:0 +playerName:Player_4 street:Preflop streetActionNo:2 action:bet amount:4 +playerName:Player_4 street:Flop streetActionNo:1 action:bet amount:2 +playerName:Player_4 street:Turn streetActionNo:1 action:bet amount:4 +playerName:Player_4 street:River streetActionNo:1 action:bet amount:4 +playerName:Player_5 street:Preflop streetActionNo:3 action:fold amount:0 +playerName:Player_6 street:Preflop streetActionNo:4 action:fold amount:0 +playerName:Player_7 street:Preflop streetActionNo:5 action:fold amount:0 diff --git a/regression-test/ps.14519420999.expected.txt b/regression-test/ps.14519420999.expected.txt new file mode 100644 index 00000000..3f42bb0a --- /dev/null +++ b/regression-test/ps.14519420999.expected.txt @@ -0,0 +1,49 @@ +Connected to MySQL on localhost. Print Hand Utility +options.site: PokerStars siteId: 2 + +From Table Hands +================ +handId: 2 tableName: Merope siteHandNo: 14519420999 gametypeId: 1 handStart: 2008-01-13 05:23:43 seats: 7 maxSeats: 10 + +From Table Gametypes +==================== +type: ring base: hold category: holdem limitType: fl hiLo: h +sb: 1 bb: 2 sbet: 2 bbet: 4 + +From Table BoardCards +===================== +Board cards: Th Jd 3c 7c 4s + +From Table HandsPlayers +======================= +playerName:Player_1 playerStartcash:65 position:2 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_2 playerStartcash:49 position:1 off Btn cards:8s 9s winnings:35 rake:1 +playerName:Player_3 playerStartcash:179 position:Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_4 playerStartcash:205 position:SB cards:?? ?? winnings:0 rake:0 +playerName:Player_5 playerStartcash:118 position:BB cards:Qh Js winnings:0 rake:0 +playerName:Player_6 playerStartcash:34 position:4 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_7 playerStartcash:135 position:3 off Btn cards:8d 5d winnings:0 rake:0 + +From Table HandsActions +======================= +playerName:Player_1 street:Preflop streetActionNo:4 action:fold amount:0 +playerName:Player_2 street:Preflop streetActionNo:5 action:call amount:2 +playerName:Player_2 street:Flop streetActionNo:2 action:call amount:2 +playerName:Player_2 street:Turn streetActionNo:2 action:bet amount:8 +playerName:Player_2 street:River streetActionNo:1 action:bet amount:4 +playerName:Player_3 street:Preflop streetActionNo:6 action:fold amount:0 +playerName:Player_4 street:Preflop streetActionNo:0 action:blind amount:1 +playerName:Player_4 street:Preflop streetActionNo:7 action:call amount:1 +playerName:Player_4 street:Flop streetActionNo:0 action:check amount:0 +playerName:Player_4 street:Flop streetActionNo:3 action:call amount:2 +playerName:Player_4 street:Turn streetActionNo:0 action:check amount:0 +playerName:Player_4 street:Turn streetActionNo:3 action:fold amount:0 +playerName:Player_5 street:Preflop streetActionNo:1 action:blind amount:2 +playerName:Player_5 street:Preflop streetActionNo:8 action:check amount:0 +playerName:Player_5 street:Flop streetActionNo:1 action:bet amount:2 +playerName:Player_5 street:Turn streetActionNo:1 action:bet amount:4 +playerName:Player_5 street:Turn streetActionNo:4 action:call amount:4 +playerName:Player_5 street:River streetActionNo:0 action:check amount:0 +playerName:Player_5 street:River streetActionNo:2 action:call amount:4 +playerName:Player_6 street:Preflop streetActionNo:2 action:fold amount:0 +playerName:Player_7 street:Preflop streetActionNo:3 action:fold amount:0 diff --git a/regression-test/ps.14519433154.expected.txt b/regression-test/ps.14519433154.expected.txt new file mode 100644 index 00000000..2754cd4d --- /dev/null +++ b/regression-test/ps.14519433154.expected.txt @@ -0,0 +1,58 @@ +Connected to MySQL on localhost. Print Hand Utility +options.site: PokerStars siteId: 2 + +From Table Hands +================ +handId: 3 tableName: Merope siteHandNo: 14519433154 gametypeId: 1 handStart: 2008-01-13 05:24:25 seats: 7 maxSeats: 10 + +From Table Gametypes +==================== +type: ring base: hold category: holdem limitType: fl hiLo: h +sb: 1 bb: 2 sbet: 2 bbet: 4 + +From Table BoardCards +===================== +Board cards: 4h 9s Ad Qc Ks + +From Table HandsPlayers +======================= +playerName:Player_1 playerStartcash:65 position:3 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_2 playerStartcash:68 position:2 off Btn cards:?? ?? winnings:0 rake:0 +playerName:Player_3 playerStartcash:179 position:1 off Btn cards:Ah 9d winnings:92 rake:4 +playerName:Player_4 playerStartcash:201 position:Btn cards:Ac Td winnings:0 rake:0 +playerName:Player_5 playerStartcash:102 position:SB cards:?? ?? winnings:0 rake:0 +playerName:Player_6 playerStartcash:34 position:BB cards:?? ?? winnings:0 rake:0 +playerName:Player_7 playerStartcash:135 position:4 off Btn cards:7c Jh winnings:0 rake:0 + +From Table HandsActions +======================= +playerName:Player_1 street:Preflop streetActionNo:3 action:fold amount:0 +playerName:Player_2 street:Preflop streetActionNo:4 action:fold amount:0 +playerName:Player_3 street:Preflop streetActionNo:5 action:call amount:2 +playerName:Player_3 street:Preflop streetActionNo:9 action:call amount:2 +playerName:Player_3 street:Flop streetActionNo:2 action:bet amount:2 +playerName:Player_3 street:Flop streetActionNo:6 action:bet amount:4 +playerName:Player_3 street:Flop streetActionNo:8 action:call amount:2 +playerName:Player_3 street:Turn streetActionNo:0 action:bet amount:4 +playerName:Player_3 street:Turn streetActionNo:2 action:bet amount:8 +playerName:Player_3 street:Turn streetActionNo:4 action:call amount:4 +playerName:Player_3 street:River streetActionNo:0 action:bet amount:4 +playerName:Player_3 street:River streetActionNo:2 action:bet amount:8 +playerName:Player_3 street:River streetActionNo:4 action:call amount:4 +playerName:Player_4 street:Preflop streetActionNo:6 action:call amount:2 +playerName:Player_4 street:Preflop streetActionNo:10 action:call amount:2 +playerName:Player_4 street:Flop streetActionNo:3 action:bet amount:4 +playerName:Player_4 street:Flop streetActionNo:7 action:bet amount:4 +playerName:Player_4 street:Turn streetActionNo:1 action:bet amount:8 +playerName:Player_4 street:Turn streetActionNo:3 action:bet amount:8 +playerName:Player_4 street:River streetActionNo:1 action:bet amount:8 +playerName:Player_4 street:River streetActionNo:3 action:bet amount:8 +playerName:Player_5 street:Preflop streetActionNo:0 action:blind amount:1 +playerName:Player_5 street:Preflop streetActionNo:7 action:bet amount:3 +playerName:Player_5 street:Flop streetActionNo:0 action:check amount:0 +playerName:Player_5 street:Flop streetActionNo:4 action:fold amount:0 +playerName:Player_6 street:Preflop streetActionNo:1 action:blind amount:2 +playerName:Player_6 street:Preflop streetActionNo:8 action:call amount:2 +playerName:Player_6 street:Flop streetActionNo:1 action:check amount:0 +playerName:Player_6 street:Flop streetActionNo:5 action:fold amount:0 +playerName:Player_7 street:Preflop streetActionNo:2 action:fold amount:0 diff --git a/regression-test/ps.15043388146.expected.txt b/regression-test/ps.15043388146.expected.txt new file mode 100644 index 00000000..300af5ed --- /dev/null +++ b/regression-test/ps.15043388146.expected.txt @@ -0,0 +1,43 @@ +Connected to MySQL on localhost. Print Hand Utility +options.site: PokerStars siteId: 2 + +From Table Hands +================ +handId: 5 tableName: Lydia siteHandNo: 15043388146 gametypeId: 3 handStart: 2008-02-04 03:04:15 seats: 6 maxSeats: 8 + +From Table Gametypes +==================== +type: ring base: stud category: studhilo limitType: fl hiLo: s + sbet: 10 bbet: 20 + +From Table BoardCards +===================== + +From Table HandsPlayers +======================= +playerName:olimpicon99 playerStartcash:531 ante:2 cards:?? ?? 8c ?? ?? ?? ?? winnings:0 rake:0 +playerName:PokerPig55 playerStartcash:158 ante:2 cards:?? ?? Kh ?? ?? ?? ?? winnings:0 rake:0 +playerName:VISTA GIRL playerStartcash:83 ante:2 cards:?? ?? 8h ?? ?? ?? ?? winnings:0 rake:0 +playerName:br1an playerStartcash:510 ante:2 cards:4c 7d 2d Qh 6d 6h 2h winnings:0 rake:0 +playerName:steffen780 playerStartcash:400 ante:2 cards:Kc 9h 9c 5c 8s ?? ?? winnings:0 rake:0 +playerName:willowdale playerStartcash:392 ante:2 cards:3s 4d 5s 4s Ad 5h 2c winnings:102 rake:5 + +From Table HandsActions +======================= +playerName:olimpicon99 street:0 streetActionNo:3 action:fold amount:0 +playerName:PokerPig55 street:0 streetActionNo:4 action:fold amount:0 +playerName:VISTA GIRL street:0 streetActionNo:5 action:fold amount:0 +playerName:br1an street:0 streetActionNo:0 action:blind amount:5 +playerName:br1an street:1 streetActionNo:0 action:check amount:0 +playerName:br1an street:2 streetActionNo:1 action:call amount:20 +playerName:br1an street:3 streetActionNo:0 action:check amount:0 +playerName:br1an street:4 streetActionNo:0 action:check amount:0 +playerName:br1an street:4 streetActionNo:2 action:call amount:20 +playerName:steffen780 street:0 streetActionNo:1 action:call amount:5 +playerName:steffen780 street:1 streetActionNo:1 action:check amount:0 +playerName:steffen780 street:2 streetActionNo:2 action:fold amount:0 +playerName:willowdale street:0 streetActionNo:2 action:call amount:5 +playerName:willowdale street:1 streetActionNo:2 action:check amount:0 +playerName:willowdale street:2 streetActionNo:0 action:bet amount:20 +playerName:willowdale street:3 streetActionNo:1 action:check amount:0 +playerName:willowdale street:4 streetActionNo:1 action:bet amount:20 diff --git a/regression-test/regression-test.sh b/regression-test/regression-test.sh new file mode 100755 index 00000000..44a1a1f7 --- /dev/null +++ b/regression-test/regression-test.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +echo "Please note for this to work you need to work on an empty database, otherwise some info (the id fields) will be off" + +rm *.found.txt +../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-3hands.txt -x +../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-3hands.txt -x + +echo "it should've reported first that it stored 3, then that it had 3 duplicates" + +./PrintHand.py -p$1 --hand=14519394979 > ps.14519394979.found.txt && colordiff ps.14519394979.found.txt ps.14519394979.expected.txt +./PrintHand.py -p$1 --hand=14519420999 > ps.14519420999.found.txt && colordiff ps.14519420999.found.txt ps.14519420999.expected.txt +./PrintHand.py -p$1 --hand=14519433154 > ps.14519433154.found.txt && colordiff ps.14519433154.found.txt ps.14519433154.expected.txt + +./PrintPlayerHudData.py -p$1 -oM > ps-flags-M-2hands.found.txt && colordiff ps-flags-M-2hands.found.txt ps-flags-M-2hands.expected.txt +./PrintPlayerHudData.py -p$1 -nPlayer_5 -oB > ps-flags-B-1hands.found.txt && colordiff ps-flags-B-1hands.found.txt ps-flags-B-1hands.expected.txt + + +../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-call-3B-preflop-cb-no2b.txt -x +echo "it should've now reported another successful store of 1 hand" +./PrintPlayerHudData.py -p$1 -nplayer3 -oE -e10 -b50 > ps-flags-CBflop.found.txt && colordiff ps-flags-CBflop.found.txt ps-flags-CBflop.expected.txt + + +../pyfpdb/CliFpdb.py -p$1 --file=ps-studhilo-ring-showdown.txt -x +echo "it should've now reported another successful store of 1 hand" +./PrintHand.py -p$1 --hand=15043388146 > ps.15043388146.found.txt && colordiff ps.15043388146.found.txt ps.15043388146.expected.txt +./PrintPlayerHudData.py -p$1 -nbr1an -o0 -e6 -b20 -cstudhilo> ps-flags-studhilo.found.txt && colordiff ps-flags-studhilo.found.txt ps-flags-studhilo.expected.txt + + +echo "if everything was printed as expected this worked" diff --git a/utils/dump_db_basedata.py b/utils/dump_db_basedata.py new file mode 100755 index 00000000..f796c8ea --- /dev/null +++ b/utils/dump_db_basedata.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import sys +import MySQLdb + +db = MySQLdb.connect("localhost", "fpdb", sys.argv[1], "fpdb") +cursor = db.cursor() +print "Connected to MySQL on localhost. Printing dev-supplied base data:" + +cursor.execute("SELECT * FROM sites") +print "Sites" +print "=====" +print cursor.fetchall() + +cursor.execute("SELECT * FROM gametypes") +print "Gametypes" +print "=========" +result=cursor.fetchall() +for i in range (len(result)): + print result[i] + +cursor.close() +db.close() diff --git a/utils/get_db_stats.py b/utils/get_db_stats.py new file mode 100755 index 00000000..182baa38 --- /dev/null +++ b/utils/get_db_stats.py @@ -0,0 +1,83 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#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, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import sys +import MySQLdb + +db = MySQLdb.connect("localhost", "fpdb", sys.argv[1], "fpdb") +cursor = db.cursor() +print "Connected to MySQL on localhost. Printing summary stats:" + +cursor.execute("SELECT id FROM Players") +print "Players:",cursor.rowcount +cursor.execute("SELECT id FROM Autorates") +print "Autorates:",cursor.rowcount + +cursor.execute("SELECT id FROM Sites") +print "Sites:",cursor.rowcount +cursor.execute("SELECT id FROM Gametypes") +print "Gametypes:",cursor.rowcount + +cursor.execute("SELECT id FROM Hands") +print "Total Hands:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.type='ring'") +print "Hands, Ring:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.type='stt'") +print "Hands, STT:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.type='mtt'") +print "Hands, MTT:",cursor.rowcount + +print "" +print "Hands per category and type" +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.limitType='cn'") +print "Hands, Cap No Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.limitType='cp'") +print "Hands, Cap Pot Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='holdem' AND Gametypes.limitType='nl'") +print "Hands, Holdem No Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='holdem' AND Gametypes.limitType='pl'") +print "Hands, Holdem Pot Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='holdem' AND Gametypes.limitType='fl'") +print "Hands, Holdem Fixed Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahi' AND Gametypes.limitType='nl'") +print "Hands, Omaha Hi No Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahi' AND Gametypes.limitType='pl'") +print "Hands, Omaha Hi Pot Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahi' AND Gametypes.limitType='fl'") +print "Hands, Omaha Hi Fixed Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahilo' AND Gametypes.limitType='nl'") +print "Hands, Omaha Hi/Lo No Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahilo' AND Gametypes.limitType='pl'") +print "Hands, Omaha Hi/Lo Pot Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='omahahilo' AND Gametypes.limitType='fl'") +print "Hands, Omaha Hi/Lo Fixed Limit:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='razz'") +print "Hands, Razz:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='studhi'") +print "Hands, Stud Hi:",cursor.rowcount +cursor.execute("SELECT Hands.id FROM Hands INNER JOIN Gametypes ON Hands.gametypeId = Gametypes.id WHERE Gametypes.category='studhilo'") +print "Hands, Stud Hi/Lo:",cursor.rowcount +print "" +cursor.execute("SELECT id FROM BoardCards") +print "Board_cards:",cursor.rowcount +cursor.execute("SELECT id FROM HandsPlayers") +print "Hands_players:",cursor.rowcount +cursor.execute("SELECT id FROM HandsActions") +print "Hands_actions:",cursor.rowcount + +cursor.close() +db.close() diff --git a/website/contact.php b/website/contact.php new file mode 100755 index 00000000..55d29da6 --- /dev/null +++ b/website/contact.php @@ -0,0 +1,29 @@ + + +
+ +

Contact

+ +

The best means of contact are on the sourceforge page: Use the bug, feature request or patch functions or just post in the forum. The forum requires a sourceforge account, but bug, feature request and patches don't seem to.

+

We also have a mailing list, to subscribe please click here. This is used for development purposes and you can also ask for help using the mailing list.

+

To be informed of fpdb updates please visit the sf download page and click on the little envelope with a plus sign in the line of the package that you want be informed off. For Windows user that will be both, Linux users should only subscribe to fpdb itself. This requires a sourceforge account, sorry.

+ +

Alternatively feel free to contact me directly:

+ +

mail: steffen(at)sycamoretest.info
+jabber/xmpp/Google Talk: steffen-laptop-temp(at)sycamoretest.info (don't email that)
+ICQ: 7806355
+MSN: steffen(at)sycamoretest.info

+ +
+ + diff --git a/website/default.conf b/website/default.conf new file mode 100644 index 00000000..dadf6290 --- /dev/null +++ b/website/default.conf @@ -0,0 +1,8 @@ +db-backend=2 +db-host=localhost +db-databaseName=fpdb +db-user=fpdb +db-password=enterYourPwHere +tv-combinedPostflop=True +bulkImport-defaultPath=default +tv-defaultPath=default diff --git a/website/docs-abreviations.php b/website/docs-abreviations.php new file mode 100755 index 00000000..0463f2be --- /dev/null +++ b/website/docs-abreviations.php @@ -0,0 +1,65 @@ + + +
+ +

Abreviations

+ +

HUD/table viewer
+================
+A3-7=3rd-7th street Complete/Raise percentage
+AF=Flop Bet/Raise percentage
+AT=River Bet/Raise percentage
+AR=Turn Bet/Raise percentage
+F3-7=3rd-7th street Fold percentage
+FF=Flop Fold percentage
+FR=River Fold percentage
+FT=Turn Fold percentage
+HD=Hands
+PF3B4B=Pre Flop 3Bet or 4Bet
+PFR=Pre Flop Raise
+Postf A=Postflop (ie. flop+turn+river) Aggression%
+Postf F=Postflop Fold %
+SD/F=Showdown/Flop=WtSD=How often player went to showdown when he saw the flop
+W$wsF=Won $ when he saw flop
+W$@SD=Won $ at showdown
+VPI3=Voluntary Put In on 3rd Street (ie. call+complete+raise)
+VPIP=Voluntary Put In Preflop (ie. call+raise)
+
+Other
+=====
+CLI=Command Line Interface (Shell, Terminal, "DOS-window")
+FTP=Full Tilt Poker
+GUI=Graphical User Interface (normal interface with buttons and menus)
+HUD=Heads-Up Display (shows stats directly in the poker software)
+PS=PokerStars
+MTT=Multi Table Tournament
+SnG=Sit and Go
+
+License
+=======
+Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt
+

+ +
+ + diff --git a/website/docs-benchmarks.php b/website/docs-benchmarks.php new file mode 100755 index 00000000..a3629827 --- /dev/null +++ b/website/docs-benchmarks.php @@ -0,0 +1,23 @@ + + +
+ +

Benchmarks

+ +

Check this page from time to time and they will come.

+ + +
+ + diff --git a/website/docs-git-instructions.php b/website/docs-git-instructions.php new file mode 100755 index 00000000..be2de79d --- /dev/null +++ b/website/docs-git-instructions.php @@ -0,0 +1,61 @@ + + +
+ +

Git Instructions

+ +

Hi, welcome to my minimal git guide for fpdb devs!
+You can use a git version just as user as well of course, but as there are generally hardly tested it is not advised.
+I'll expand this on request, if you have any questions just send me a mail at steffen(at)sycamoretest.info. There's also a bunch of instructions at http://www.assembla.com/spaces/fpdb/trac_git_tool

+ +

0. Getting it

+

To get git for gentoo just do emerge git -av
+To get it for Windows go to http://code.google.com/p/msysgit/downloads/list and install it. +

1. Cloning the fpdb git tree

+

Just create a new directory (lets say ~/fpdb/ ), go into it and type:
+git clone git://git.assembla.com/fpdb.git

+

2. Making your changes

+

You can use whatever you want to do edit the files. I personally use nedit and occassionally Eclipse.

+

3. Making a (local) commit

+

Unlike in svn you don't need to be online to make your commits. First we need to tell git what to commit, so go to the root of your fpdb directory and type:
+git-add--interactive
+Now press u and enter. It will display a list of all changed files. If you want to commit all files just press * and enter twice to return to the main menu. If you want to commit only certain ones press the number of the file and enter and repeat until you have all the files. Then press enter again to return to the main menu.
+If you added any new files press a and Enter, then type the number of your new file and press Enter twice. Press q to leave git-add--interactive.
+Now create a file for your commit message (I call it since_last_commit.txt) but don't add this to the repository. In the first line of this file put a summary of your changes. Then give some details of your changes, try to mention anything non-trivial and definitely any user-visible bug fixes.
+Then run this:
+git-commit -F since_last_commit.txt
+

4a. Pushing the changes to your own public git tree

+

Do this OR 4b, not both.
+todo

+

4b. Preparing changeset for emailing/uploading

+

Do this OR 4a, not both.
+todo

+

5. Pulling updates from the main tree

+

todo

+

License

+

Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt

+ + +
+ + diff --git a/website/docs-hudHowTo.php b/website/docs-hudHowTo.php new file mode 100755 index 00000000..cf501c44 --- /dev/null +++ b/website/docs-hudHowTo.php @@ -0,0 +1,169 @@ + + +
+ +

How To Use the HUD

+ +

3 September, 2008

+ +

fpdb version alpha 3

+ +

Initial Configuration

+ +

Install and configure the import/tracker program as detailed elsewhere. You should have this line in your default.conf file.

+ +imp-callFpdbHud=True + +

When you downloaded fpdb you got an example HUD configuration file named HUD_config.xml.

+ +

1. Open the subdirectory where you installed fpdb.

+ +

2. Make a backup copy of HUD_config.xml.

+ +

3. Check that the db_user and db_pass parameters are the ones you specified during database setup. This line is near the bottom of your config file and specifies the database parameters to be used.

+ +<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="fpdb" db_type="fpdb"></database> + +

This should allow you to use the HUD with the stats and layout in the example configuration file.

+ +

Running the HUD

+ +

1. Open fpdb and select Auto Import from the menu. The fpdb main screen will change to show the autoimport dialog.

+ +Image of HUD + +

Check that the path is pointing to your hand history subdirectory, if it is not, then click the browse button and select it. ?You can also adjust the interval between imports. Smaller intervals will get your updated HUD data more often, but might cause lag. If you experience lag, increase the interval.

+ +

2. Click "Start Autoimport" to start the import. fpdb will automatically start the HUD. When the HUD starts it will open a HUD main window.

+ +Image of HUD + +

2. This window currently has no purpose other than providing a close button that will cause the HUD to exit.

+ +

3. Play a hand of poker (good luck). A few seconds after the completion of the hand the stat windows should overlay the poker client window.

+ +Image of HUD + +

You will also see a small main window for each table that has a HUD. Clicking the close button on that window will kill the HUD stat windows for that table. The stat windows will not go away automatically when you close the table.

+ + + +

4. Adjust the positions of the stat windows. By default, the stat windows are created without decorations (title bar, border, etc.). Double clicking on a stat will add the decorations to that stat window. You can then use the title bar to move the window and double click again to make the decorations disappear.

+ + + + + +

5. So play some poker: raise, bet, float, get all-in. You can find out what each stat is by hovering the mouse over the stat and looking at the tool tip. The tool tip also has the name of the player that the stat corresponds to, so it is useful in figuring out which stat window goes where if your windows are not in the right place. You can also get a pop up window with additional stats by single clicking on a stat.

+ + + +

These windows do not automatically update when a new hand is imported, but they can be moved around the same way the stat window are moved. Single clicking anywhere on the popup will make it disappear.

+ +

Configuring Stat Layouts

+ +

OK, back to the HUD_config.xml file--saving a backup would be a good idea. Before you ask, yes, there will be a neat configuration function in the HUD, to make this quicker and easier. We thought you would prefer to have the HUD now rather than wait for us to write the configuration code.

+ +

1. Open your HUD_config.xml file in you text editor and scroll down to site entry for the layout you want to configure. For example, if you want to change a layout for Pokerstars, find the line that starts like this.

+ +<site site_name="PokerStars" ... + +

Below that line you will find several blocks of lines defining the stat layouts for tables with the various numbers of seats. For example the layout for 6-seated tables looks like this:

+ +<layout max="6" width="792" height="546" fav_seat="0>
+<location seat="1" x="681" y="119"> </location>
+<location seat="2" x="681" y="301"> </location>
+<location seat="3" x="487" y="369"> </location>
+<location seat="4" x="226" y="369"> </location>
+<location seat="5" x="0" y="301"> </location>
+<location seat="6" x="0" y="119"> </location>
+</layout>
+ +

The first line of this layout specifies that it is for a 6-max (max="6") table that has been sized to 792 x 546 (width="792" height="546"). The fav_seat parameter is not used at this time.

+ +

The next 6 lines specify where the stat windows are placed on the poker client window. The x and y positions are measured from the inside upper left of the poker client window. That is x = 0, y = 0 would be the first usable pixel to the right of the window border and below the title bar.

+ +

So if you are using the layout in the example above and decide that the stat window for seat 3 is being place 9 pixels too high, you would change the line for seat="3" to be:

+ +<location seat="3" x="487" y="378"> </location> + +

If you use smaller or larger client windows you should correct the width and height parameters so that they are up-to-date when automatic resizing is implemented.

+ +

Configuring the Stats Shown in the stat windows

+ +

The definition of the stat window stats is in the "supported games" paragraph of the HUD_config.xml file. For example:

+ +<game game_name="studhilo" db="fpdb" rows="2" cols="3">
+<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
+<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
+<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
+<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
+<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
+<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
+</game>
+ +

The first line specifies the game that this stat paragraph is used for (game = "studhilo") and the number of rows and columns in the stat window. In this case we have specified 2 rows and 3 columns so we can have 2x3 = 6 stats. Rows and columns are numbered from 0, so the 3 columns are numbered 0, 1, and 2.

+ +

The subsequent lines in the stat paragraph specify which stats are displayed in the various parts of the window. In this example, vpip is displayed in col 0, row 0.

+ +

So to create stat windows with 4 columns of 2 rows you would change the cols parameter in the first line to cols = "4" and add 2 additional rows to specify the stats for row 2, col 3 and row 1, col 3.

+ +

The click and tip parameters in this paragraph are not currently used. The popup parameter is explained in the next section.

+ +

Configuring Popup Windows

+ +

Each stat location can display a different popup window when clicked. In the example just above, each of the stats has the "default" popup specified. You can see the definition of the default popup by scrolling farther down in your config file. It should look like this.

+ +<popup_windows>
+<pu pu_name="default">
+<pu_stat pu_stat_name = "n"> </pu_stat>
+<pu_stat pu_stat_name = "vpip"> </pu_stat>
+<pu_stat pu_stat_name = "pfr"> </pu_stat>
+...
+<pu_stat pu_stat_name = "ffreq_4"> </pu_stat>
+</pu>
+</popup_windows>
+ +

You can create a new popup by making a new pu elelment, with a new name and a new list of stats. You then specify that popup name in the popup parameter in one or more of your stats.

+ +

Currently Supported Stats

+ +
+
a_freq_1
Flop/4th aggression frequency.
+
a_freq_2
Turn/5th aggression frequency.
+
a_freq_3
River/6th aggression frequency.
+
a_freq_4
7th street aggression frequency.
+
cb_1
Flop continuation bet.
+
cb_2
Turn continuation bet.
+
cb_3
River continuation bet.
+
cb_4
7th street continuation bet.
+
f_BB_steal
Folded BB to steal.
+
f_SB_steal
Folded SB to steal.
+
ffreq_1
Flop/4th fold frequency.
+
ffreq_2
Turn/5th fold frequency.
+
ffreq_3
River/6th fold frequency.
+
ffreq_4
7th fold frequency.
+
n
Number of hands played.
+
pfr
Preflop (3rd street) raise.
+
saw_f
Saw flop/4th.
+
steal
Steal %.
+
three_B_0
Three bet preflop/3rd.
+
vpip
Voluntarily put $ in the pot.
+
wmsd
Won $ at showdown.
+
wtsd
Went to SD when saw flop/4th.
+
WMsF
Won $ when saw flop/4th.
+
+ + + \ No newline at end of file diff --git a/website/docs-install-gentoo.php b/website/docs-install-gentoo.php new file mode 100755 index 00000000..43d2f02b --- /dev/null +++ b/website/docs-install-gentoo.php @@ -0,0 +1,85 @@ + + +
+ +

Installing in Gentoo Linux

+ +

Last checked: 3 Aug 2008, git99

+ +These instructions are for Gentoo GNU/Linux, but if you adapt the steps installing and starting stuff it should work on any other OS as well.

+ +1. Install everything. Check if anything is already installed and if it is remove it from the command.

+ +For mysql:
+emerge mysql mysql-python pygtk -av
+/etc/init.d/mysql start
+rc-update add mysql default

+ +For postgresql:
+emerge postgresql pygresql pygtk
+/etc/init.d/postgresql start
+rc-update add postgresql default
+ +

+2. Manual configuration steps
+
+emerge --config mysql
+The --config step will ask you for the mysql root user - set this securely, we will create a seperate account for fpdb
+

+3. Create a mysql user and a database
+Now open a shell (aka command prompt aka DOS window):
+Click Start, then Run. In the opening window type "cmd" (without the inverted commas) and then click OK. A windows with a black background should open.

+ +Type (replacing yourPassword with the root password for MySQL you specified during installation):
+mysql --user=root --password=yourPassword

+ +It should say something like this:
+Welcome to the MySQL monitor. Commands end with ; or \g.
+Your MySQL connection id is 4
+Server version: 5.0.60-log Gentoo Linux mysql-5.0.60-r1
+
+Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
+
+mysql>
+
+Now create the actual database. The default name is fpdb, I recommend you keep it. Type this:
+CREATE DATABASE fpdb;
+ +Next you need to create a user. I recommend you use the default fpdb. Type this (replacing newPassword with the password you want the fpdb user to have - this can, but for security shouldn't, be the same as the root mysql password):
+GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;

+ +Copy the .conf file from this directory to ~/.fpdb/profiles/default.conf and edit it according to what you configured just now, in particular you will definitely have to put in the password you configured. I know this is insecure, will fix it before stable release.
+
+4. Guided installation steps
+Run the GUI as described in readme-user and click the menu database -> recreate tables
+
+That's it! Now see readme-user.txt for usage instructions.
+
+License
+=======
+Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt

+ + +
+ + diff --git a/website/docs-install-windows.php b/website/docs-install-windows.php new file mode 100755 index 00000000..341e2f15 --- /dev/null +++ b/website/docs-install-windows.php @@ -0,0 +1,208 @@ + + +
+ +

Before You Begin

+

Most people should install using the Installer. These instructions have not been updated recently, but can serve as a guide to someone who knows what he is doing. Unless you have a special reason for installing manually, you really should be using the installer.

+ +

Vista Users

+

The installer does not install mysql properly on Microsoft Vista installations, due to the UAC. You should first install mysql using this how to (pdf). Then run the installer. The installer will detect the mysql installation and not reintstall.

+ +

Installing in Windows

+ +
+

These instructions were made with Windows XP. They should also work with Windows NT / 2000 / 2003 and 2008. Please report any differences to gmic at users.sourceforge.net. +

If you're still using Win3/95/98/ME then you should switch to GNU/Linux, *BSD or WinXP.

+ +
+windows install guide screenshot +

1. Click here to open the MySQL Download Page. Click on the "No, thanks..." link to see the download links for the MySQL installer.

+
+ +
+windows install guide screenshot +

2. Click on one of the HTTP or FTP download links to download the zip file (mysql-5.0.67-win32.zip).

+
+ +
+windows install guide screenshot +

3. Unzip the setup file to a folder of your choice and double-click on it. On the welcome screen click "Next".

+
+ +
+windows install guide screenshot +

4. As the setup type "Typical" should be selected. Then click "Next". On the following screen click "Install" and installation will begin.

+
+ +
+windows install guide screenshot +

5. Before the installation ends an ad for MySQL Enterprise edition will appear. Just click "Next" two times.

+
+ +
+windows install guide screenshot +

6. Now make sure that "Configure the MySQL Server now" is checked and click "Finish".

+
+ +
+windows install guide screenshot +

7. You are now looking at the MySQL Configuration Wizard. Click "Next".

+
+ +
+windows install guide screenshot +

8. Make sure "Detailed Configuration" is selected. Then click "Next. Now "Developer machine" should be selected. Click "Next".

+
+ +
+windows install guide screenshot +

9. On this screen "Multifunctional Database should be selected. Click "Next". On the next screen (InnoDB Tablespace) just click "Next".

+
+ +
+windows install guide screenshot +

10. Now "Decision Support" should be selected. Click "Next". Now make sure "Enable TCP/IP Networking" IS selected. Then click "Next".

+
+ +
+windows install guide screenshot +

11. Here "Standard Character Set" should be selected. Click "Next". Now make sure "Install As Windows Service" is selected.

+
+ +
+windows install guide screenshot +

12. Now choose a root password. This will NOT be the password for your poker database. Click "Next".

+
+ +
+windows install guide screenshot +

13. On this last screen of the Configuration Wizard just click "Execute." A few success messages will appear. Click "Finish".

+
+ +
+windows install guide screenshot +

14. Now click the Windows Start Button and then click "Run". Click into the white space of the new window, type cmd and hit ENTER.

+
+ +
+windows install guide screenshot +

15. In the newly appeared console window type cd "%PROGRAMFILES%\MySQL\MySQL Server 5.0\bin" and hit ENTER.

+
+ +
+windows install guide screenshot +

16. Type mysql --user=root --password=yourPassword and hit ENTER (replace yourPassword with your chosen root password).

+
+ +
+windows install guide screenshot +

17. A few lines followed by mysql> will appear. This is the MySQL command prompt.

+
+ +
+windows install guide screenshot +

18. We will now create your poker database. Type CREATE DATABASE fpdb; and hit ENTER. "Query OK" says we were successful.

+
+ +
+windows install guide screenshot +

19. Type the following, replace newPassword with a password of your choice and hit ENTER:

+

GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;

+
+ +
+windows install guide screenshot +

20. Again it says "Query OK". Type exit and hit ENTER to exit the MySQL prompt. Leave this window open. We will need it later.

+
+ +
+windows install guide screenshot +

21. Click here, save the file python-2.5.2.msi where you want and double-click on it. In case of a warning window click "Execute".

+
+ +
+windows install guide screenshot +

22.Click "Next" three times. Python will install. Then click finish.

+
+ +
+windows install guide screenshot +

23. Click here, save MySQL-python-1.2.2.win32-py2.5.exe to a folder of your choice and double click it. In case of a warning window click "Execute". Click "Next" three times. The Python API for MySQL will install. Click "Finish".

+
+ +
+windows install guide screenshot +

24. In the console window (which we left open) now type: mkdir c:\gtk and hit ENTER. Leave the window open again, we'll need it.

+

Now click here and save the gtk zip file gtk+-bundle-2.12.11.zip to a folder of your choice. Unzip its contents to C:\gtk

+
+ +
+windows install guide screenshot +

25. Now right-click "My Computer" (on your Desktop) and click on "Properties". Now click on the tab "Advanced".

+
+ +
+windows install guide screenshot +

26. Click the button "Environ Variables". In the lower list of the new window click on "Path" (possibly you need to scroll).

+
+ +
+windows install guide screenshot +

27.Now click on the"Edit" button and a new window will pop up. To the value of the variable append ;C:\gtk\bin Click Ok three times.

+
+ +
+windows install guide screenshot +

28. Click here, save the file pycairo-1.4.12-1.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning window click "Execute". Now click "Next" three times. The pycairo graphics library API for Python will install. Click "Finish".

+
+ +
+windows install guide screenshot +

29. Click here, save the file pygobject-2.14.1-1.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning click "Execute". Now click "Next" three times. The Python Gobject API will install. Click "Finish".

+
+ +
+windows install guide screenshot +

30. Click here, save the file pygtk-2.12.1-2.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning click "Execute". Now click "Next" three times. The Python API for Gtk+ will install. Click "Finish".

+
+ +
windows install guide screenshot +

31. In the console window now type: mkdir "%homepath%\Application Data\fpdb" and hit ENTER. Copy the file "default.conf" from the docs folder of your fpdb git to the directory C:\%homepath%\Application Data\fpdb\.

+
+ +
+windows install guide screenshot +

32. Now open the file "default.conf" in WordPad (Start > Programs > Accessoirs > WordPad) and replace the password in the dbpassword line with your chosen password for the fpdb user.

+
+ +
+windows install guide screenshot +

33. Now start FPDB by double-clicking on the file fpdb.py in the folder fpdb. A console window should open up and shortly thereafter the fpdb application window should be visible. Click on the menu "Database" and select "Create or Recreate Tables".

+
+

Congratulations! Your fpdb installation is complete! Now you can use the bulk importer to import your hands into fpdb. +

+
+ +

A word on privelege separation: fpdb should not require root/Administrator rights to run. If it does it is a bug or serious misconfiguration, please let us know.

+

License

+

Trademarks of third parties have been used under Fair Use or similar laws.

+

Copyright 2008 Steffen Jobbagy-Felso

+

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 as published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license can be found in fdl-1.2.txt. The program itself is licensed under AGPLv3, see agpl-3.0.txt

+ + + + + diff --git a/website/docs-overview.php b/website/docs-overview.php new file mode 100755 index 00000000..3d2781d2 --- /dev/null +++ b/website/docs-overview.php @@ -0,0 +1,84 @@ + + +
+ +

Overview

+

+Summary
+=======
+A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt
+
+But you could send all my hand histories to yourself!
+=====================================================
+At the end of the day this comes down to a question of trust, but unlike Windows and the poker client software you don't have to trust fpdb blindly. You can:
+- Verify the source code yourself.
+- Convince or pay someone to verify the source code for you.
+- Use a personal firewall to completely block fpdb from the Internet
+- (for the uber-paranoid) Get yourself the free virtualisation software VirtualBox, set up a VM (virtual machine) to run fpdb but run the poker software on your real PC. Then cut the VM off the Internet, fpdb doesn't need it. If you have a PC made in the last few years this should run fast enough as well. Note that most Windows licenses do NOT permit you to use two Windows installations at once, even if they are on the same PC.
+
+Requirements
+============
+Software requirements are listed in requirements.txt
+As for hardware, my main test machine is a Pentium 3-M 800 with 256 RAM and Gentoo GNU/Linux
+(running the poker client through what most people will call emulation). So this
+program will have to work on that. If you run an even more ancient machine and
+its too slow let me know and I'll see what I can do :)
+
+Why Free Software?
+==================
+This program is released under the terms of the free/libre software license AGPL3 as released by the FSF. The AGPL3 protects your rights and those of the wider community. As Richard Stallman, one of the founders of the free software movement, put it: "Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer." (well, it is both really, like the right to vote used to be free)
+
+For example, a "pirated" copy of proprietary software X is free of charge, but you don't actually have a legal right to use it, you don't have any possibility to fix its bugs and you certainly don't have any legal right to share it with your friends. You also won't be able to get support, often not even security fixes. Actually, even if you pay hundreds of pounds for your program they deny your right to fix their errors for them. Imagine buying a car where you're not permitted (under threat of jail) to replace broken parts..
+
+With free/libre software (also known as open source software, or short FOSS or FLOSS) on the other hand you get all these freedoms:
+(note: the legally binding terms are in the license text, this is merely an amateur summary so normal people don't have to read pages of legalese)
+
+Freedom 0: The freedom to use: To run the program, for any purpose. Free of Charge.
+Freedom 1: The freedom to study and help yourself. This freedom guarantees your right to study and learn from the source code of the program, and to fix it if it is broken. If you're not a programmer yourself the developers will generally be happy to fix it for you, often even for free. Failing that you can always pay someone from the money you saved on not having to pay for it.
+Freedom 2: The freedom to be a decent human being and help your neighbour: I don't threaten you with lawsuits or jail time if you share with your friends and neighbours, subject to the very modest restrictions of the AGPL3.
+Freedom 3: The freedom to improve the program and release your improvements to the public (or parts thereof) so that the whole community benefits. Note that you are PERMITTED, but not REQUIRED to distribute your changes. If you do distribute your changes you must do so under the terms of the AGPL3 however.
+
+Note that this is the license - I retain full copyright over my code, including the right to change the license for future versions. I do not intend to do this however. In any case, any version I released under AGPL3 remains available under that license forever, or more accurately until my copyright expires at which point it goes into the public domain.
+
+I reject the concept of software patents as a crime and under the European Patent Agreement software patents - even if you mislabel them as "computer-implemented inventions" or whatever - are explicitly prohibited.
+
+Can I get/use this under a different license?
+=============================================
+The short answer: Maybe.
+The long one: As detailed, I fully support what the FSF does and aims to achieve with the GPL. However, I realise that many free software developers don't object to closed source, some don't even object to closed source profiteering of their charity, and I don't think I have any right to go and tell them they're wrong.
+So if anyone wishes to use all or part of my code in another free software/open source project with an AGPL3-incompatible license such as BSD then let me know and we'll figure out a solution that makes everyone happy.
+If you wish to use all or part of this in closed source let me know how much if anything that is worth to you and I'm sure we'll be able to reach an agreement. Note that you are NOT permitted to just use fpdb code in closed source development whether in-house or by an independent software developer, you will NEED an additionally agreement with me to get fpdb under different licensing conditions.
+
+
+License of this Document
+========================
+The views expressed in this document are those of Steffen Jobbagy-Felso, other members of the fpdb team and external contributors may or may not agree.
+
+Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt
+

+ + + +
+ + diff --git a/website/docs-requirements.php b/website/docs-requirements.php new file mode 100755 index 00000000..166424af --- /dev/null +++ b/website/docs-requirements.php @@ -0,0 +1,170 @@ + + +
+ +

Requirements

+

+I recommend using a free/libre operating system, meaning a GNU/Linux distribution or a BSD variant (e.g. Gentoo GNU/Linux or OpenBSD) for ethical and practical reasons. Would you buy a car where you're prohibited from opening the bonnet under threat of jail? If the answer is no you should by the same logic not use closed source software for real money Poker :)
+
+Unfortunately you will always need one piece of unfree software: The poker client itself. Although not a direct dependency of fpdb you obviously will have a hard time putting this to productive use without running some poker client. As far as I know, only unfree clients are available. If you know better please let me know!
+
+If you can be bothered please do contact your poker site(s) and ask them to release free/libre clients, even if it is only for Windows. But lets be realistic, the chance of a positive answer is very low. Also, even unfree Linux client would of course be a great step forward
+
+In Windows use of the environment installer is recommended, pls see our sf download page. For Gentoo Linux we have an ebuild and for Ubuntu Linux we have (partial) instructions. If you use a different Linux or a BSD and have trouble please IM, email or post in the forums. Fpdb has been reported to work on MacOSX, but installation of the requirements is relatively painful. Any instructions for people to use would be much appreciated.
+
+Make new entries in this format:
+Program Name
+a. Optional?
+b. Required Version and Why
+c. Project Webpage
+d. License

+

Database backend - MySQL

+

These two are required if you want to use MySQL as backend, which is the recommended choice due to lack of testing and polish of PostgreSQL support.

+

MySQL
+a. Optional?
+ Choose MySQL or PostgreSQL
+b. Required Version and Why
+ At least 3.23 required due to mysql-python.
+ I use 5.0.54 and 5.0.60-r1 (GNU/Linux) and 5.0.51b (Windows).
+c. Project Webpage
+ http://www.mysql.com
+d. License
+ GPL2
+
+mysql-python
+a. Optional?
+ Required if you want to use MySQL backend
+b. Required Version and Why
+ I use 1.2.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://sourceforge.net/projects/mysql-python/
+d. License
+ SF lists GNU General Public License (GPL), Python License (CNRI Python License), Zope Public License.
+ Project states GPL without version in Pkg-info.

+ +

Database backend - PostgreSQL

+

These two are required if you want to use PostgreSQL as backend

+

PostgreSQL
+a. Optional?
+ Choose MySQL or PostgreSQL
+b. Required Version and Why
+ I use 8.0.15 (GNU/Linux) and 8.3.3 (Windows) but I am not aware of any incompatibilities
+ with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://www.postgresql.org
+d. License
+ BSD License
+
+psycopg
+a. Optional?
+ Required if you want to use PostgreSQL backend
+b. Required Version and Why
+ I use 2.0.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://initd.org/projects/psycopg2
+d. License
+ GPL2 according to Gentoo's ebuilds
+
+

Required for everyone

+

Python
+a. Optional?
+ Required.
+b. Required Version and Why
+ I use 2.4.4 and 2.5.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://www.python.org
+d. License
+ Python License
+
+

GTK+ and dependencies
+a. Optional?
+ Required.
+b. Required Version and Why
+ I use 2.12.9 but it should run with 2.10 or higher. That is needed as I used MessageDialog updates
+c. Project Webpage
+ Main: http://www.gtk.org/
+ API spec: http://library.gnome.org/devel/gtk/2.12/
+ Windows DLs (get the bundle unless you know what you're doing): http://www.gtk.org/download-windows.html
+d. License
+ LGPL2
+
+PyCairo
+a. Optional?
+ Required.
+b. Required Version and Why
+ ?
+c. Project Webpage
+ main: http://www.pygtk.org
+d. License
+ LGPL2.1
+
+PyGObject
+a. Optional?
+ Required.
+b. Required Version and Why
+ ?
+c. Project Webpage
+ main: http://www.pygtk.org
+d. License
+ LGPL2.1
+
+PyGTK
+a. Optional?
+ Required.
+b. Required Version and Why
+ ?
+c. Project Webpage
+ main: http://www.pygtk.org
+d. License
+ LGPL2.1

+

Requirements for the graphing function

+

These are only required if you wish to use the graphing function, and fpdb will otherwise function without them

+

Numpy
+a. Optional?
+ Optional.
+b. Required Version and Why
+ I use 1.0.4 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://numeric.scipy.org/
+d. License
+ BSD according to Gentoo's ebuild
+
+matplotlib
+a. Optional?
+ Optional.
+b. Required Version and Why
+ I use 0.91.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.
+c. Project Webpage
+ http://matplotlib.sourceforge.net/
+d. License
+ BSD according to Gentoo's ebuild

+ +License (of this file)
+=======
+Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt

+ + + +
+ + diff --git a/website/docs-usage.php b/website/docs-usage.php new file mode 100755 index 00000000..a9132f2c --- /dev/null +++ b/website/docs-usage.php @@ -0,0 +1,64 @@ + + +
+ +

Usage instructions

+ +

Before you do this make sure you setup the dependencies, the database, user, tables and config file.
+
+Running it
+==========
+If you have python setup properly you can execute it by double clicking pyfpdb/fpdb.py.
+
+Note however that all error messages are currently only printed if you call it from a shell. It'll be much easier to diagnose possible problems (which are likely in alpha stage) if you run it from a shell. In Windows XP it seems to automatically open a shell window with the fpdb window where you can see the command line output.
+
+In Linux/MacOS/*BSD, e.g. if its in /home/sycamore/fpdb/, do this:
+cd /home/sycamore/fpdb/pyfpdb
+python fpdb.py
+
+That will start the main GUI.
+
+Have a look at the menus, the stuff that is marked todo is not yet implemented.
+
+The main things are the bulk importer and the table viewer. To use the importer open it from the menu (import files and directories). You can set a few options at the bottom, then select a folder or single file in the main are and click Import. Please report any errors by one of the contacts listed in readme-overview.txt.
+Currently this will block the interface, but you can open another instance of this program e.g. if you wanna play whilst a big import is running.
+
+Please check the output at the shell for errors, if there are any please get in touch by one of the methods listed in readme-overview.txt
+
+Table Viewer (tv)
+=================v +To use the table viewer open it from the menu, select the hand history file of the table you're at, and click the Import&Read&Refresh button. The abbreviations there are explained in abbreviations.txt, but feel free to ask. Note that most poker software will only create the file once the first hand you payed to play is finished.
+In each column there is either just the number (hand count for current stake, range of seats and type of game) or a percentage and the number of hands that this percentage is based on. For example, in W$@SD (won $ at shodown) the number in brackets is how many showdowns that player has seen.
+
+Reimporting
+===========
+Currently on most updates a reimport of the whole database is required. To do this open fpdb, click the menu Database and select Create/Recreate tables. Then import all your history files again.
+
+License
+======= +Trademarks of third parties have been used under Fair Use or similar laws.
+
+Copyright 2008 Steffen Jobbagy-Felso
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+Version 1.2 as published by the Free Software Foundation; with
+no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
+Texts. A copy of the license can be found in fdl-1.2.txt
+
+The program itself is licensed under AGPLv3, see agpl-3.0.txt

+ + +
+ + diff --git a/website/docs.php b/website/docs.php new file mode 100755 index 00000000..d0749d68 --- /dev/null +++ b/website/docs.php @@ -0,0 +1,37 @@ + + +
+ +

Documentation

+ + + + + + + +
+ + diff --git a/website/features.php b/website/features.php new file mode 100755 index 00000000..e1df9f1e --- /dev/null +++ b/website/features.php @@ -0,0 +1,47 @@ + + +
+ +

Features

+ +

Backend, Distribution
+=====================
+- Choice of MySQL/InnoDB or PostgreSQL. (not tested on PostgreSQL)
+- It is possible to run the database on one PC, the importer on another, and then access the database with the table viewer or HUD from a third PC. (note: do NOT do this unencrypted over an untrusted network like your employer's LAN or the Internet!)
+
+Site/Game Support
+=================
+- Initially only full support for PS, FTP coming soon
+- Supports Holdem, Omaha Hi and Omaha Hi/Lo. Stud and Razz coming soon.
+ +- Supports No Limit, Pot Limit, Fixed Limit NL, Cap NL and Cap PL
+ Note that currently it does not display extra stats for NL/PL so usefulness is limited for these limit types. Suggestions welcome, I don't play these.
+- Supports ring/cash games, SnG/MTT coming soon
+
+Tableviewer (tv)
+===========
+Tv takes a history filename and loads the appropriate players' stats and displays them in a tabular format. These stats currently are:
+ - VPIP, PFR and Preflop 3B/4B (3B/4B is not quite correct I think)
+ + - Raise and Fold % on flop, turn and river. Fold only counts hands when someone raised. This can be displayed per street or as one combined value each for aggression and folding.
+ - Number of hands this is based on.
+ - SD/F (aka WtSD, proportion of hands where player went to showdown after seeing flop)
+ - W$wSF (Won $ when seen Flop)
+ - W$@SD (Won $ at showdown)
+ For all stats it also displays how many hands this particular is based on

+ + +
+ + diff --git a/website/footer.php b/website/footer.php new file mode 100755 index 00000000..abe37b45 --- /dev/null +++ b/website/footer.php @@ -0,0 +1 @@ + diff --git a/website/fpdb.png b/website/fpdb.png new file mode 100644 index 00000000..24de1545 Binary files /dev/null and b/website/fpdb.png differ diff --git a/website/header.php b/website/header.php new file mode 100755 index 00000000..df88b6cb --- /dev/null +++ b/website/header.php @@ -0,0 +1,17 @@ + + + + + + + fpdb - The free poker database - <?php echo ($PAGE_TITLE) ?> + + + + + + + + diff --git a/website/img/00.mySqlWebsite1.jpg b/website/img/00.mySqlWebsite1.jpg new file mode 100644 index 00000000..2b83b68a Binary files /dev/null and b/website/img/00.mySqlWebsite1.jpg differ diff --git a/website/img/01.mySqlWebsite2.jpg b/website/img/01.mySqlWebsite2.jpg new file mode 100644 index 00000000..458a9e90 Binary files /dev/null and b/website/img/01.mySqlWebsite2.jpg differ diff --git a/website/img/02.mySqlSetup1.jpg b/website/img/02.mySqlSetup1.jpg new file mode 100644 index 00000000..f98a8e0a Binary files /dev/null and b/website/img/02.mySqlSetup1.jpg differ diff --git a/website/img/03.mySqlSetup3.jpg b/website/img/03.mySqlSetup3.jpg new file mode 100644 index 00000000..295306f3 Binary files /dev/null and b/website/img/03.mySqlSetup3.jpg differ diff --git a/website/img/04.mySqlSetup5.jpg b/website/img/04.mySqlSetup5.jpg new file mode 100644 index 00000000..a236687c Binary files /dev/null and b/website/img/04.mySqlSetup5.jpg differ diff --git a/website/img/05.mySqlSetup7.jpg b/website/img/05.mySqlSetup7.jpg new file mode 100644 index 00000000..17db5ea5 Binary files /dev/null and b/website/img/05.mySqlSetup7.jpg differ diff --git a/website/img/06.mySqlConfig1.jpg b/website/img/06.mySqlConfig1.jpg new file mode 100644 index 00000000..eaa02523 Binary files /dev/null and b/website/img/06.mySqlConfig1.jpg differ diff --git a/website/img/07.mySqlConfig2.jpg b/website/img/07.mySqlConfig2.jpg new file mode 100644 index 00000000..5ee23448 Binary files /dev/null and b/website/img/07.mySqlConfig2.jpg differ diff --git a/website/img/08.mySqlConfig4.jpg b/website/img/08.mySqlConfig4.jpg new file mode 100644 index 00000000..36a0aaea Binary files /dev/null and b/website/img/08.mySqlConfig4.jpg differ diff --git a/website/img/09.mySqlConfig7.jpg b/website/img/09.mySqlConfig7.jpg new file mode 100644 index 00000000..ae39d7dc Binary files /dev/null and b/website/img/09.mySqlConfig7.jpg differ diff --git a/website/img/10.mySqlConfig8.jpg b/website/img/10.mySqlConfig8.jpg new file mode 100644 index 00000000..5fe1dae1 Binary files /dev/null and b/website/img/10.mySqlConfig8.jpg differ diff --git a/website/img/11.mySqlConfig10.jpg b/website/img/11.mySqlConfig10.jpg new file mode 100644 index 00000000..7bd1066c Binary files /dev/null and b/website/img/11.mySqlConfig10.jpg differ diff --git a/website/img/12.mySqlConfig11.jpg b/website/img/12.mySqlConfig11.jpg new file mode 100644 index 00000000..74ed5781 Binary files /dev/null and b/website/img/12.mySqlConfig11.jpg differ diff --git a/website/img/13.run.jpg b/website/img/13.run.jpg new file mode 100644 index 00000000..71f66ee4 Binary files /dev/null and b/website/img/13.run.jpg differ diff --git a/website/img/14.shellCdToMySql.jpg b/website/img/14.shellCdToMySql.jpg new file mode 100644 index 00000000..6c0b104f Binary files /dev/null and b/website/img/14.shellCdToMySql.jpg differ diff --git a/website/img/15.shellMySqlRootLogin.jpg b/website/img/15.shellMySqlRootLogin.jpg new file mode 100644 index 00000000..3710b16a Binary files /dev/null and b/website/img/15.shellMySqlRootLogin.jpg differ diff --git a/website/img/16.shellMySqlPrompt.jpg b/website/img/16.shellMySqlPrompt.jpg new file mode 100644 index 00000000..772f861c Binary files /dev/null and b/website/img/16.shellMySqlPrompt.jpg differ diff --git a/website/img/17.shellMySqlCreateDB.jpg b/website/img/17.shellMySqlCreateDB.jpg new file mode 100644 index 00000000..05c654d7 Binary files /dev/null and b/website/img/17.shellMySqlCreateDB.jpg differ diff --git a/website/img/18.shellMySqlCreateUser.jpg b/website/img/18.shellMySqlCreateUser.jpg new file mode 100644 index 00000000..7d637f8e Binary files /dev/null and b/website/img/18.shellMySqlCreateUser.jpg differ diff --git a/website/img/19.shellMySqlUserCreated.jpg b/website/img/19.shellMySqlUserCreated.jpg new file mode 100644 index 00000000..099b01c7 Binary files /dev/null and b/website/img/19.shellMySqlUserCreated.jpg differ diff --git a/website/img/20.pythonInst.jpg b/website/img/20.pythonInst.jpg new file mode 100644 index 00000000..cc9c518d Binary files /dev/null and b/website/img/20.pythonInst.jpg differ diff --git a/website/img/21.pythonInst4.jpg b/website/img/21.pythonInst4.jpg new file mode 100644 index 00000000..7c5d2582 Binary files /dev/null and b/website/img/21.pythonInst4.jpg differ diff --git a/website/img/22.mySqlPythonInst1.jpg b/website/img/22.mySqlPythonInst1.jpg new file mode 100644 index 00000000..f74f01a5 Binary files /dev/null and b/website/img/22.mySqlPythonInst1.jpg differ diff --git a/website/img/23.shellMkDirGtk.jpg b/website/img/23.shellMkDirGtk.jpg new file mode 100644 index 00000000..cb8317cc Binary files /dev/null and b/website/img/23.shellMkDirGtk.jpg differ diff --git a/website/img/24.setGtkPath1.jpg b/website/img/24.setGtkPath1.jpg new file mode 100644 index 00000000..030b2a00 Binary files /dev/null and b/website/img/24.setGtkPath1.jpg differ diff --git a/website/img/25.setGtkPath2.jpg b/website/img/25.setGtkPath2.jpg new file mode 100644 index 00000000..d88a8382 Binary files /dev/null and b/website/img/25.setGtkPath2.jpg differ diff --git a/website/img/26.setGtkPath3.jpg b/website/img/26.setGtkPath3.jpg new file mode 100644 index 00000000..29439d2e Binary files /dev/null and b/website/img/26.setGtkPath3.jpg differ diff --git a/website/img/27.pycairoInst.jpg b/website/img/27.pycairoInst.jpg new file mode 100644 index 00000000..71eb8e8d Binary files /dev/null and b/website/img/27.pycairoInst.jpg differ diff --git a/website/img/28.pygobjectInst.jpg b/website/img/28.pygobjectInst.jpg new file mode 100644 index 00000000..87fb4cb7 Binary files /dev/null and b/website/img/28.pygobjectInst.jpg differ diff --git a/website/img/29.pyGtkInst.jpg b/website/img/29.pyGtkInst.jpg new file mode 100644 index 00000000..593bacf4 Binary files /dev/null and b/website/img/29.pyGtkInst.jpg differ diff --git a/website/img/30.shellMkDirProfiles.jpg b/website/img/30.shellMkDirProfiles.jpg new file mode 100644 index 00000000..c5e25a19 Binary files /dev/null and b/website/img/30.shellMkDirProfiles.jpg differ diff --git a/website/img/31.editDbProfile.jpg b/website/img/31.editDbProfile.jpg new file mode 100644 index 00000000..db20e795 Binary files /dev/null and b/website/img/31.editDbProfile.jpg differ diff --git a/website/img/32.startFpdb.jpg b/website/img/32.startFpdb.jpg new file mode 100644 index 00000000..d95fdf40 Binary files /dev/null and b/website/img/32.startFpdb.jpg differ diff --git a/website/img/Screenshot-2-Site-HUD.png b/website/img/Screenshot-2-Site-HUD.png new file mode 100644 index 00000000..5c1283a5 Binary files /dev/null and b/website/img/Screenshot-2-Site-HUD.png differ diff --git a/website/img/Screenshot-Graph-v137.png b/website/img/Screenshot-Graph-v137.png new file mode 100644 index 00000000..ae281d71 Binary files /dev/null and b/website/img/Screenshot-Graph-v137.png differ diff --git a/website/img/Screenshot-Stacked-Everleaf-137.jpg b/website/img/Screenshot-Stacked-Everleaf-137.jpg new file mode 100644 index 00000000..1db7358f Binary files /dev/null and b/website/img/Screenshot-Stacked-Everleaf-137.jpg differ diff --git a/website/img/docs.HudHowTo1.png b/website/img/docs.HudHowTo1.png new file mode 100644 index 00000000..078a4429 Binary files /dev/null and b/website/img/docs.HudHowTo1.png differ diff --git a/website/img/docs.HudHowTo2.png b/website/img/docs.HudHowTo2.png new file mode 100644 index 00000000..b6e88564 Binary files /dev/null and b/website/img/docs.HudHowTo2.png differ diff --git a/website/img/docs.HudHowTo3.png b/website/img/docs.HudHowTo3.png new file mode 100644 index 00000000..aa768736 Binary files /dev/null and b/website/img/docs.HudHowTo3.png differ diff --git a/website/img/docs.HudHowTo4.png b/website/img/docs.HudHowTo4.png new file mode 100644 index 00000000..2610a30a Binary files /dev/null and b/website/img/docs.HudHowTo4.png differ diff --git a/website/img/docs.HudHowTo5.png b/website/img/docs.HudHowTo5.png new file mode 100644 index 00000000..29e42675 Binary files /dev/null and b/website/img/docs.HudHowTo5.png differ diff --git a/website/img/docs.HudHowTo6.png b/website/img/docs.HudHowTo6.png new file mode 100644 index 00000000..f4248931 Binary files /dev/null and b/website/img/docs.HudHowTo6.png differ diff --git a/website/img/docs.HudHowTo7.png b/website/img/docs.HudHowTo7.png new file mode 100644 index 00000000..e3bada61 Binary files /dev/null and b/website/img/docs.HudHowTo7.png differ diff --git a/website/index.php b/website/index.php new file mode 100755 index 00000000..14764ed1 --- /dev/null +++ b/website/index.php @@ -0,0 +1,24 @@ + + +
+ +

Welcome!

+ +

fpdb is a database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. The software is currently in alpha status, which means some of the features are not working yet. As it's open source you're free to add any feature you like or modify the existing ones to fit your needs.

+ +

To see what fpdb can do, go to the features page. If you're ready to test it, take a look at the documentation.

+ +
+ + diff --git a/website/license.php b/website/license.php new file mode 100755 index 00000000..d7c3fa9b --- /dev/null +++ b/website/license.php @@ -0,0 +1,687 @@ + + +
+ +

License

+ +
+
+                    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/>.
+
+
+
+ +
+ + diff --git a/website/screenshots.php b/website/screenshots.php new file mode 100755 index 00000000..fb13138e --- /dev/null +++ b/website/screenshots.php @@ -0,0 +1,25 @@ + + +

Screenshots

+ +

Importing hands:

+

Table viewer:

+

HUD:

+

Graph viewer:

+

Working with 2 sites:

+

Working stacked:

+ +
+ + diff --git a/website/sidebar.php b/website/sidebar.php new file mode 100755 index 00000000..06bd6ca4 --- /dev/null +++ b/website/sidebar.php @@ -0,0 +1,13 @@ + diff --git a/website/style.css b/website/style.css new file mode 100644 index 00000000..d12f4779 --- /dev/null +++ b/website/style.css @@ -0,0 +1,52 @@ +body {margin: 0px; padding: 0px; background-color: #fff; font-family: "Verdana", "Arial", sans-serif; font-size: 13px; color: #333;} + +a {text-decoration: none; color: #336984;} + +a:hover {color: #e00000;} + +img {border: 0px;} + +h1 {font-size: 23px;} + +li {padding: 3px;} + + +/* ------------------------------------------------- */ +#header { + padding: 20px 20px 10px 20px; + background-color: #8BB9D1; + border-bottom: 10px solid #4690B5; + color: #fff; + font-size: 31px; +} + +#logo a { + font-size: 32px; + color: #5C5C49; +} + + +/* ------------------------------------------------- */ +#main { margin-left: 210px; margin-right: 15px; } +.winInst div { width: 906px; } +.screenshot { background-color: #E8F1F6; padding: 0px; margin: 10px auto; padding: 10px; } +.screenshot img { padding: 2px; border: 1px solid #87aade; } +.screenshot p { margin: 0; } +#screens { float: left; margin: 1em; text-align: center; } + +/* ------------------------------------------------- */ +#sidebar {background-color: #E8F1F6; width: 180px; padding: 10px; float: left;} + +#sidebar ul {padding: 0px; margin: 0px; list-style-position: inside;} + +#sidebar ul li {border-bottom: 1px solid #D1E3EC; padding: 3px;} + +#sidebar ul li:hover {background-color: #fff;} + +#sidebar a {text-decoration: none;} + +dl dt { float: left; width: 200px; font-weight: bold; } + + +/* ------------------------------------------------- */ +#footer { clear: both; text-align: right; padding: 1em 2em; }