Desktop applications written in PHP

Source: Internet
Author: User
Tags php file php code prepare


Copy php content to clipboard PHP code:

<?php
$winmain =wb_create_window (Null,appwindow, ' 21-point game ', wbc_center,wbc_center,800,495,0,0);
Wb_create_control ($winmain, Label, ' banker ', 20,15,40,30,lb_1,0,0,0);
Wb_create_control ($winmain, Label, ' Player ', 20,200,40,30,lb_2,00,0,0);
Wb_create_control ($winmain, Frame, ', 80,40,120,150,fr_pc_1,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 220,40,120,150,fr_pc_2,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 360,40,120,150,fr_pc_3,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 500,40,120,150,fr_pc_4,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 640,40,120,150,fr_pc_5,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 645,230,120,150,fr_u_5,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 500,230,120,150,fr_u_4,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 360,230,120,150,fr_u_3,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 220,230,120,150,fr_u_2,0,0,0 ');
Wb_create_control ($winmain, Frame, ', 80,230,120,150,fr_u_1,0,0,0 ');
Wb_create_control ($winmain, Label, ', 35,305,25,20,lb_u_t,0,0,0 ');
Wb_create_control ($winmain, Label, ', 35,110,25,20,lb_p_t,0,0,0 ');
Wb_create_control ($winmain, pushbutton, ' Licensing ', 320,400,70,25,b_go,0x00000002,0,0);
Wb_create_control ($winmain, pushbutton, ' Stop ', 435,400,70,25,b_change,0x00000002,0,0);
Wb_create_control ($winmain, Label, ', 110,95,60,60,lb_pc_1,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 250,95,60,60,lb_pc_2,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 390,95,60,60,lb_pc_3,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 530,95,60,60,lb_pc_4,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 670,95,60,60,lb_pc_5,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 110,285,60,60,lb_u_1,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 250,285,60,60,lb_u_2,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 390,285,60,60,lb_u_3,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 530,285,60,60,lb_u_4,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 670,285,60,60,lb_u_5,0x00000800,0,0 ');
Wb_create_control ($winmain, Label, ', 70,20,90,20,pc_mon,0,0,0 ');
Wb_create_control ($winmain, Label, ', 70,205,90,20,u_mon,0,0,0 ');

point_include.php file


<?php
For ($i =1 $i <=13; $i + +) {
Switch ($i) {
Case 1j=1 $key = ' A ';
Case 11j=10 $key = ' J ';
Case 12j=10 $key = ' Q ';
Case 13j=10 $key = ' K ';
Default
$key = $j = $i;
}
$card ["Black Peach \n$key"]= $j;
$card ["Red Peach \n$key"]= $j;
$card ["Plum flower \n$key"]= $j;
$card ["Side \ \ \n$key"]= $j;
}
$contorl _id=array (
' B_go ' =>1001, ' B_change ' =>1002,
' Me_start ' =>2001, ' Me_remon ' =>2002, ' Me_author ' =>2003, ' me_quit ' =>idclose,
' Lb_1 ' =>3001, ' lb_2 ' =>3002, ' lb_u_t ' =>3003, ' lb_p_t ' =>3004,
' Pc_mon ' =>3005, ' U_mon ' =>3006,
' Lb_pc_1 ' =>3101, ' lb_pc_2 ' =>3102, ' lb_pc_3 ' =>3103, ' lb_pc_4 ' =>3104, ' lb_pc_5 ' =>3105,
' Lb_u_1 ' =>3201, ' lb_u_2 ' =>3202, ' lb_u_3 ' =>3203, ' lb_u_4 ' =>3204, ' lb_u_5 ' =>3205,
' Fr_pc_1 ' =>4001, ' fr_pc_2 ' =>4002, ' fr_pc_3 ' =>4003, ' fr_pc_4 ' =>4004, ' fr_pc_5 ' =>4005,
' Fr_u_1 ' =>5001, ' fr_u_2 ' =>5002, ' fr_u_3 ' =>5003, ' fr_u_4 ' =>5004, ' fr_u_5 ' =>5005,
);
foreach ($contorl _id as $key => $value) {
if (!defined (Strtoupper ($key))) define (Strtoupper ($key), $value);
}
?>


21POINT.PHPW file


<?php
Set_time_limit (0);
Include_once (' include/winbinder.php ');
Include_once (' form/point_include.php ');
Include_once (' form/21point.form.php ');

Class Ponit {
Public $key _id;
Private $user _point=10000;
Private $pc _point=10000;
Private $card;
Private $player = ' user ';
Private $new _term=false;
Private $remon =false;
Public function __construct ($winmain, $card) {
$f =file_get_contents (' form/db.db ');
List ($this->user_point, $this->pc_point) =explode (' | ', $f);
$this->window= $winmain;
$this->card= $card;
$this->prepare ();
}
Private function prepare () {
Wb_set_image ($this->window, ' Form/hyper.ico ');
Wb_create_control ($this->window,menu,array (
' Game (&g) ', NULL,
Array (Me_start, "Start \tcrtl+n", "", ", ' CTRL + N"),
Array (Me_remon, "re-scoring"),
Array (Me_author, "author"),
Null
Array (Me_quit, "Exit \tcrtl+q", ",", ' ctrl+q '),
Null
));
Wb_set_text (Wb_get_control ($this->window,u_mon), $this->user_point. ' min ');
Wb_set_text (Wb_get_control ($this->window,pc_mon), $this->pc_point. ' min ');
$font =wb_create_font ("Arial", N, null, fta_bold);
Wb_set_font (Wb_get_control ($this->window,lb_1), $font);
Wb_set_font (Wb_get_control ($this->window,lb_2), $font);
$font =wb_create_font ("Arial",), NULL, fta_bold);
For ($i =1 $i <=5; $i + +) {
Wb_set_font (Wb_get_control ($this->window, (3100+ $i)), $font);
Wb_set_font (Wb_get_control ($this->window, (3200+ $i)), $font);
}
}
Private Function Start () {
$this->player= ' user ';
$this->new_term=true;
$this->clear ();
$this->play ();
Wb_set_enabled (Wb_get_control ($this->window,b_go), true);
Wb_set_enabled (Wb_get_control ($this->window,b_change), true);
}
Private Function Stop () {
Wb_set_enabled (Wb_get_control ($this->window,b_go), false);
Wb_set_enabled (Wb_get_control ($this->window,b_change), false);
}
Private Function Change_player () {
$this->stop ();
$this->player= ' PC ';
$this->play ();
}
Private Function Total ($num =0, $win) {
Static $u _tem, $p _tem;
if (Empty ($u _tem) | | Empty ($p _tem) | | $this->remon==true) {
$u _tem= $this->user_point;
$p _tem= $this->pc_point;
$this->remon=false;
}
if (Strtoupper ($win) = = ' U ') {
$u _tem+= $num;
$p _tem-= $num;
}else{
$u _tem-= $num;
$p _tem+= $num;
}
$this->user_point= $u _tem;
$this->pc_point= $p _tem;
Wb_set_text (Wb_get_control ($this->window,u_mon), $this->user_point. ' min ');
Wb_set_text (Wb_get_control ($this->window,pc_mon), $this->pc_point. ' min ');
$f =fopen (' form/db.db ', ' WB ');
Fwrite ($f, $this->user_point. "|" $this->pc_point);
Fclose ($f);
}
Private Function Remon () {
$this->remon=true;
$this->user_point=10000;
$this->pc_point=10000;
Wb_set_text (Wb_get_control ($this->window,u_mon), $this->user_point. ' min ');
Wb_set_text (Wb_get_control ($this->window,pc_mon), $this->pc_point. ' min ');
$f =fopen (' form/db.db ', ' WB ');
Fwrite ($f, $this->user_point. "|" $this->pc_point);
Fclose ($f);
}
Private Function Clear () {
Wb_set_text (Wb_get_control ($this->window,lb_u_t), "");
Wb_set_text (Wb_get_control ($this->window,lb_p_t), "");
For ($i =1 $i <=5; $i + +) {
Wb_set_text (Wb_get_control ($this->window, (4000+ $i));
Wb_set_text (Wb_get_control ($this->window, (5000+ $i));
Wb_set_text (Wb_get_control ($this->window, (3100+ $i));
Wb_set_text (Wb_get_control ($this->window, (3200+ $i));
}
}
Private Function Play () {
Static $card _tem=array (), $i =0, $j =0, $user _total=0, $pc _total=0;
if ($this->new_term==true) {
$card _tem= $this->card;
$this->new_term=false;
$user _total=0;
$PC _total=0;
$i =0; $j = 0;
}
if ($this->player== ' user ') {
$i + +;
$card _key=array_rand ($card _tem);
$card _value= $card _tem[$card _key];
$user _total+= $card _value;
Wb_set_text (Wb_get_control ($this->window,lb_u_t), $user _total. ' Point ');
Wb_set_text (Wb_get_control ($this->window, (5000+ $i)), $card _key);
Wb_set_text (Wb_get_control ($this->window, (3200+ $i)), $card _value);
if ($i >=5 && $user _total<=21) {
$this->total (' U ');
$sel =wb_message_box ($this->window, "Congratulations, 5, all small, the player wins!" Do you still want to play? ", ' Victory ', Wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}elseif ($user _total>21) {
$this->total (' P ');
$sel =wb_message_box ($this->window, "Unfortunately, more than 21 points, the dealer won!" Do you still want to play? ", ' failure ', wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}
}else{
$j + +;
$card _key=array_rand ($card _tem);
$card _value= $card _tem[$card _key];
$pc _total+= $card _value;
Wb_set_text (Wb_get_control ($this->window,lb_p_t), $pc _total. ' Point ');
Wb_set_text (Wb_get_control ($this->window, (4000+ $j)), $card _key);
Wb_set_text (Wb_get_control ($this->window, (3100+ $j)), $card _value);
if ($j >=5 && $pc _total<=21) {
$this->total (' P ');
$sel =wb_message_box ($this->window, "the dealer 5 Zhang all small, the banker wins!" Do you still want to play? ", ' failure ', wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}elseif ($pc _total>21) {
if ($pc _total-$card _value< $user _total) {
$this->total (' U ');
$sel =wb_message_box ($this->window, "Congratulations, the dealer points more than 21 points, the player wins!" Do you still want to play? ", ' Victory ', Wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}else{
$pc _total= $pc _total-$card _value;
Wb_set_text (Wb_get_control ($this->window,lb_p_t), $pc _total. ' Point ');
Wb_set_text (Wb_get_control ($this->window, (4000+ $j));
Wb_set_text (Wb_get_control ($this->window, (3100+ $j));
if ($pc _total>= $user _total) {
$this->total (' P ');
$msg = ($pc _total== $user _total)? " The two points are the same, the dealer wins! Do you still want to play? ":" The dealer points bigger than you, the crop wins! Do you still want to play? ";
$sel =wb_message_box ($this->window, $msg, ' failure ', wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}else{
$this->total (' U ');
$sel =wb_message_box ($this->window, "Congratulations, the dealer points are smaller than you, the player wins!" Do you still want to play? ", ' Victory ', Wbc_yesno);
$sel ==1 $this->start (): $this->stop ();
}
}
}else{
Usleep (800000);
$this->play ();
}
}
unset ($card _tem[$card _key]);
}

Private Function author () {
$inf = "Hello everyone, I am machine_ horse, \ n \ nthe first desktop application in my life, \ n \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ^_^. \n\n\n\n\t\t Author: machine_ horse ";
$author _window=wb_create_window ($this->window,modaldialog, ' author profile ', Wbc_center, Wbc_center, 360, 180, 0x00000000, 0 );
Wb_set_handler ($author _window, ' Author_handler ');
$image =wb_create_control ($author _window,frame, ' 123 ', 0,0,128,144,110,wbc_image);
Wb_create_control ($author _window,label, $inf, 140,20,200,150,120,wbc_image);
Wb_set_image ($image, ' form/author.bmp ', nocolor);
}
Public Function main () {
Switch ($this->key_id) {
Case Idclose:
Wb_destroy_window ($this->window); Break
Case Me_start:
$this->start (); Break
Case Me_author:
$this->author (); Break
Case B_GO:
$this->play (); Break
Case B_change:
$this->change_player (); Break
Case Me_remon:
$this->remon (); Break
}
}
}
$WBD =new ponit ($winmain, $card);
Wb_set_handler ($winmain, ' go_to ');
Wb_main_loop ();
function go_to ($window, $id) {
Global $WBD;
$WBD->key_id= $id;
return $WBD->main ();
}
function Author_handler ($this _window, $id) {
Switch ($id) {
Case Idclose:
Wb_destroy_window ($this _window);
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.