-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compile xdebug from source cause `pecl install xdebug` wont work anymore setup snakes and ladders kata with first unit test
- Loading branch information
Andre Rademacher
committed
Oct 7, 2023
1 parent
150b6eb
commit fac010d
Showing
8 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,19 @@ RUN apk add \ | |
--update \ | ||
autoconf \ | ||
g++ \ | ||
make \ | ||
&& pecl install \ | ||
xdebug-2.7.2 | ||
make | ||
|
||
ADD xdebug-2.7.2.tgz / | ||
RUN cd /xdebug-2.7.2 \ | ||
&& phpize \ | ||
&& ./configure --enable-xdebug \ | ||
&& make \ | ||
&& make install | ||
|
||
# done, copy binaries from build stage | ||
FROM php:7.0-cli-alpine as final | ||
LABEL maintainer="[email protected]" | ||
COPY --from=build /usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so | ||
COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini | ||
COPY --from=composer/composer:2.2-bin /composer /usr/local/bin/composer | ||
USER 1000 | ||
WORKDIR /codewars/php70 |
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Snakes and ladders | ||
|
||
## Introduction | ||
Snakes and Ladders is an ancient Indian board game regarded today as a worldwide classic. | ||
It is played between two or more players on a gameboard having numbered, gridded squares. | ||
A number of "ladders" and "snakes" are pictured on the board, | ||
each connecting two specific board squares. (Source Wikipedia) | ||
|
||
## Task | ||
|
||
Your task is to make a simple class called SnakesLadders. | ||
The test cases will call the method play(die1, die2) | ||
independantly of the state of the game or the player turn. | ||
The variables die1 and die2 are the die thrown in a turn | ||
and are both integers between 1 and 6. | ||
The player will move the sum of die1 and die2. | ||
|
||
## The board | ||
|
||
 | ||
|
||
## Rules | ||
|
||
1. There are two players and both start off the board on square 0. | ||
2. Player 1 starts and alternates with player 2. | ||
3. You follow the numbers up the board in order 1=>100. | ||
4. If the value of both die are the same then that player will have another go. | ||
5. Climb up ladders. | ||
The ladders on the game board allow you to move upwards and get ahead faster. | ||
If you land exactly on a square that shows an image of the bottom of a ladder, | ||
then you may move the player all the way up to the square at the top of the ladder | ||
(even if you roll a double). | ||
6. Slide down snakes. | ||
Snakes move you back on the board because you have to slide down them. | ||
If you land exactly at the top of a snake, slide move the player all the way | ||
to the square at the bottom of the snake or chute (even if you roll a double). | ||
7. Land exactly on the last square to win. | ||
The first person to reach the highest square on the board wins. | ||
But there's a twist! If you roll too high, your player "bounces" off the last square | ||
and moves back. You can only win by rolling the exact number needed to land | ||
on the last square. For example, if you are on square 98 and roll a five, | ||
move your game piece to 100 (two moves), then "bounce" back to 99, 98, 97 (three, four then five moves). | ||
8. If the Player rolled a double and lands on the finish square “100” | ||
without any remaining moves then the Player wins the game and does not have to roll again. | ||
|
||
## Returns | ||
|
||
- Return `Player n Wins!`. | ||
Where n is winning player that has landed on square 100 without any remainding moves left. | ||
- Return `Game over!` if a player has won and another player tries to play. | ||
- Otherwise, return `Player n is on square x`. | ||
Where n is the current player and x is the sqaure they are currently on. | ||
|
||
[See this kata in Codewars](https://www.codewars.com/kata/587136ba2eefcb92a9000027) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kata\SnakesAndLadders; | ||
|
||
final class SnakesLadders | ||
{ | ||
public function __construct() | ||
{ | ||
|
||
} | ||
|
||
public function play(int $die1, int $die2): string | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kata\SnakesAndLadders; | ||
|
||
use Generator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class SnakesLaddersTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providePlay | ||
*/ | ||
public function testPlay(array $expectedOutput, array $diceThrows) | ||
{ | ||
$game = new SnakesLadders(); | ||
foreach ($diceThrows as $key => $diceThrow) { | ||
self::assertSame($expectedOutput[$key], $game->play(...$diceThrow)); | ||
} | ||
} | ||
|
||
public function providePlay(): Generator | ||
{ | ||
yield 'Player 1 just throws 1 & 1' => [ | ||
[ | ||
'Player 1 is on square 38', | ||
], | ||
[ | ||
[1, 1], | ||
] | ||
]; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.