PHP Classes

PHP Darts Counter Game: Manage darts games with multiple players

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 55 All time: 10,546 This week: 571Up
Version License PHP version Categories
ycr_task7 1.0The PHP License5PHP 5, Games
Description 

Author

This package can manage darts games with multiple players.

It provides a game class that can join several players passing their names.

The game class can also process player shots by accounting for the points they earned in each dart shot.

It can also return the current standing of all players and determine if the game ended.

Innovation Award
PHP Programming Innovation award winner
April 2022
Winner
Darts is a popular game that allows several people to play by throwing dart arrows at a target board. Each player can earn points depending on how close the hands stick to the center of the board.

This package can help manage each player's score until each game ends to determine who won.

This way, the package can help keep track of the game's progress accurately, so the players do not have to remember how many points each player is scoring.

Manuel Lemos
Picture of Alex McArrow
  Performance   Level  
Name: Alex McArrow <contact>
Classes: 3 packages by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 4091115 in Russian Federation Russian Federation
Week rank: 411 Up22 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php

require './loader.php';

use
Darts\?ircular\PointCounter;
use
Darts\Game;

$drop_limit = 5;
$player_list = [
   
'Alex',
   
'Oleg',
   
'Victor',
   
'Roman'
];
$radiuses = [
   
1 => 10,
   
5 => 5,
   
10 => 1
];
$max_radius = max(array_keys($radiuses));

$pointcounter = new PointCounter();
$pointcounter->set_radius_point($radiuses);
$game = new Game($pointcounter);
$game->set_drop_limit($drop_limit);


foreach (
$player_list as $value) {
   
$game->join_player($value);
}

foreach (
$player_list as $value) {
    for (
$i = 0; $i < $drop_limit; $i++) {
       
$x = mt_rand(0, $max_radius * 100) / 100;
       
$y = mt_rand(0, $max_radius * 100) / 100;
       
$game->drop_dart($value, $x, $y);
    }
}


print_r($game->get_result());
print_r($game->get_tech_result());


  Files folder image Files  
File Role Description
Files folder imageDarts (2 files)
Accessible without login Plain text file dev.php Example Example script
Accessible without login Plain text file loader.php Aux. Auxiliary script

  Files folder image Files  /  Darts  
File Role Description
  Plain text file Game.php Class Class source
  Plain text file Player.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:55
This week:0
All time:10,546
This week:571Up