Location: PHPKode > projects > An adaptation of the Uno cards game > Uno/main.php
<?php
/*
 * Created on 06-oct.-2006
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
require ('include/winbinder.php');
require('ia.class.php');
require('interface.class.php');


$ia = new ia();
$interface = new Itrf();


wb_main_loop();

function callback_main($window,$id,$ctrl,$param1,$param2) {
	global $ia,$interface;
	if($id == IDCLOSE) {
		wb_destroy_window($window);
		return 0;
	} elseif($id == ID_PIOCHE) {
		if($ia->state == $ia->me) {
        	if($pioche = $ia->pioche()) {
        		if($ia->piochenb < 1) {
        			$ia->piochenb++;
        			$ia->players[$ia->me]['cartes'][] = $pioche; 
	        		$interface->refresh_bas();
        		}
        	}
        }
        return 0;
	} elseif($id == ID_BOT) {
		wb_destroy_timer($window,ID_BOT);
		$ia->ia_bot();
		return 0;
	} elseif($id == ID_PASSE) {
		if($ia->state == $ia->me) {
			$ia->nextPlayer();
		}
		return 0;
	} elseif(isset($interface->frame_ctrl[$ctrl])) {
		if($ia->state == $ia->me) {
			$carteid = $interface->frame_ctrl[$ctrl];
			$carte = $ia->players[$ia->me]['cartes'][$carteid];
			if($ia->state == $ia->me) {
				if($carte == 'jok') {
					$interface->jok4 = 'jok';
					$interface->select_couleur($carteid);
				} elseif($carte == "+4") {
					$interface->jok4 = '+4';
					//$ia->add4();
					$interface->select_couleur($carteid);
				} elseif($ia->compare($carte,$ia->tas)) {
					unset($ia->players[$ia->me]['cartes'][$carteid]);
					
					$old = $ia->players[$ia->me]['cartes'];
					$ia->players[$ia->me]['cartes'] = array();
					foreach($old as $value) {
						if($value!='') {
							$ia->players[$ia->me]['cartes'][] = $value;
						}
					}
					
					$interface->add_centre($carte);
					$interface->refresh_bas();
					$ia->nextPlayer();
				}
			}
		}
	}
	
}

function callback_couleurs($window,$id) {
	global $interface,$ia;	

	switch($id) {
		case 1:
			$c = "blue";
			break;
		case 2:
			$c = "yellow";
			break;
		case 3:
			$c = "red";
			break;
		case 4:
			$c = "green";
			break;
	}
	$interface->add_centre($interface->jok4,$c);
	$interface->jok4 = '';
	$interface->refresh_bas();
	$ia->nextPlayer();
	wb_destroy_window($window);
}


?>
Return current item: An adaptation of the Uno cards game