Giter Site home page Giter Site logo

freelancerwebro / the-hero-game Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 511 KB

A hero game developed using PHP. It simulates a battle between two characters.

PHP 100.00%
php oop-principles clean-code unit-testing object-oriented-programming game-development composer hero-game battle hero

the-hero-game's Introduction

The hero game

The task simulates a battle between two characters, a hero and a beast. Both have a set of randomly generated abilities: health, strength, defence, speed and luck.

To start the battle, run the following command in the console. Also you can to run 'index.php' file in browser.

php index.php

Battle output:

Start Battle!

hero health: 94
hero strength: 73
hero speed: 45
hero defence: 53
hero luck: 16

beast health: 77
beast strength: 73
beast speed: 44
beast defence: 46
beast luck: 29

ROUND: 1
Attacker: Hero
Attacker Health: 94
Defender: Wild Beast
Defender Health: 50

ROUND: 2
Attacker: Wild Beast
Attacker Health: 50
Defender: Hero
Defender Health: 74

ROUND: 3
Attacker: Hero
Attacker Health: 74
Defender: Wild Beast
Defender Health: 23

ROUND: 4
Attacker: Wild Beast
Attacker Health: 23
Defender: Hero
Defender Health: 54

ROUND: 5
Attacker: Hero
Attacker Health: 54
Defender: Wild Beast
Defender Health: 0

Winner is: Hero
GAME OVER!!

Unit tests can be run by the following command:

vendor/bin/phpunit tests/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.