Skip to content

Commit

Permalink
Merge pull request #603 from MartinThoma/apply-pre-commit
Browse files Browse the repository at this point in the history
MAINT: Apply pre-commit
  • Loading branch information
coding-horror committed Mar 5, 2022
2 parents 15b0f61 + 93e1a78 commit 375eb83
Show file tree
Hide file tree
Showing 549 changed files with 6,320 additions and 5,609 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ repos:
rev: v4.1.0
hooks:
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
Expand Down
20 changes: 10 additions & 10 deletions 00_Utilities/DotnetUtils/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ dotnet_naming_rule.private_members_should_be_pascal_case.style = camel_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum, delegate
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_private_members.applicable_kinds = property, method, field, event
dotnet_naming_symbols.non_private_members.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
Expand All @@ -80,19 +80,19 @@ dotnet_naming_symbols.private_members.applicable_accessibilities = private

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.camel_case.required_prefix =
dotnet_naming_style.camel_case.required_suffix =
dotnet_naming_style.camel_case.word_separator =
dotnet_naming_style.camel_case.required_prefix =
dotnet_naming_style.camel_case.required_suffix =
dotnet_naming_style.camel_case.word_separator =
dotnet_naming_style.camel_case.capitalization = camel_case


Expand Down
4 changes: 2 additions & 2 deletions 00_Utilities/DotnetUtils/DotnetUtils/PortInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public record PortInfo(
string LangPath, string Lang, string Ext, string ProjExt,
string[] CodeFiles, string[] Slns, string[] Projs
) {

private static readonly EnumerationOptions enumerationOptions = new() {
RecurseSubdirectories = true,
MatchType = MatchType.Simple,
Expand All @@ -34,7 +34,7 @@ public record PortInfo(
int.TryParse(parts[0], out var n) && n > 0 ? // ignore utilities folder
n :
(int?)null,
specialGameNames.TryGetValue(parts[1], out var specialName) ?
specialGameNames.TryGetValue(parts[1], out var specialName) ?
specialName :
parts[1].Replace("_", "").Replace("-", "")
);
Expand Down
2 changes: 1 addition & 1 deletion 00_Utilities/DotnetUtils/DotnetUtils/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
void generateMissingProjs() {
foreach (var item in infos.Where(x => x.Projs.None())) {
// We can't use the dotnet command to create a new project using the built-in console template, because part of that template
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
// if there's already such a file, it might try to overwrite it.

var projText = item.Lang switch {
Expand Down
13 changes: 5 additions & 8 deletions 00_Utilities/bas2perl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
my $Pedantic= 0;
my $Indent= 0;

my %Vars; # num | str | anm | ast
my %Vars; # num | str | anm | ast
my @Data;
my %Code;
open(FH, $File);
Expand Down Expand Up @@ -278,7 +278,7 @@ sub PRINT {
push @Out, $Par;
}

my $Out= join(". ", @Out);
my $Out= join(". ", @Out);
if ($Enter) { $Out.= qq|. "\\n"|; }
return "print ".$Out;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ sub FORMULA {
if ($Vars{$Key}!~ /^a/) { next; }
$Str=~ s/\$$Key\((.*?)\)/\$$Key\[$1\]/g;
}

if ($Cond==1) {
$Str=~ s/<>/ ne /g;
$Str=~ s/=/ eq /g;
Expand All @@ -357,7 +357,7 @@ sub FORMULA {


sub SMARPLIT {
my ($Str, $Sep, $Nin)= @_;
my ($Str, $Sep, $Nin)= @_;
my @Parts;
my $Text= "";
my $Flag= 0;
Expand All @@ -373,8 +373,5 @@ sub SMARPLIT {
$Text.= $Char;
}
if ($Text) { push @Parts, &TRIM($Text); }
return @Parts;
return @Parts;
}



6 changes: 3 additions & 3 deletions 00_Utilities/find-unimplemented.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Program to show unimplemented games by language, optionally filtered by
* Program to show unimplemented games by language, optionally filtered by
* language
*
*
* Usage: node find-unimplemented.js [[[lang1] lang2] ...]
*
*
* Adapted from find-missing-implementtion.js
*/

Expand Down
2 changes: 1 addition & 1 deletion 00_Utilities/jvmTestUtils/kotlin/test/ConsoleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ abstract class ConsoleTest {

private fun String.trimWhiteSpace() =
replace("[\\s]+".toRegex(), " ")
}
}
5 changes: 2 additions & 3 deletions 00_Utilities/yatol.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

foreach my $Dir (@Langs) {
printf("%$Tab\s", $Dir);
}
}
print "\n";

my $Count;
Expand All @@ -39,7 +39,7 @@
if ($Ret>1) { printf("%$Tab\s", "YES"); $Sum{$Dir}++; }
else { printf("%$Tab\s", " ");}
}
print "\n";
print "\n";
}


Expand All @@ -57,4 +57,3 @@
printf("%$Tab\s", "$Per");
}
print "\n";

2 changes: 1 addition & 1 deletion 01_Acey_Ducey/csharp/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AceyDucey
/// </summary>
internal class GameState
{

/// <summary>
/// How much money does the player have at the moment?
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion 01_Acey_Ducey/d/aceyducey.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main()
{
writeln("YOU WIN!!!");
cash += bet;
}
}
else
{
writeln("Sorry, you lose.");
Expand Down
2 changes: 1 addition & 1 deletion 01_Acey_Ducey/java/src/AceyDucey.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ public void intro() {
System.out.println("A VALUE BETWEEN THE FIRST TWO.");
System.out.println("IF YOU DO NOT WANT TO BET, INPUT: 0");
}
}
}
4 changes: 2 additions & 2 deletions 01_Acey_Ducey/java/src/AceyDucey17.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public static void main(String[] args) {
System.out.println("""
ACEY DUCEY CARD GAME
CREATIVE COMPUTING MORRISTOWN, NEW JERSEY
ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER
THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP
YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING
Expand Down
2 changes: 1 addition & 1 deletion 01_Acey_Ducey/java/src/AceyDuceyGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public static void main(String[] args) {
keepPlaying = game.playAgain();
} while (keepPlaying);
}
}
}
2 changes: 1 addition & 1 deletion 01_Acey_Ducey/javascript/aceyducey.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async function main() {
}
}
}
if (bet == 0)
if (bet == 0)
{
// User chose not to bet.
print('CHICKEN!!');
Expand Down
1 change: 0 additions & 1 deletion 01_Acey_Ducey/pascal/object-pascal/aceyducey.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
Acey_Ducey:= TGame.Create;
Acey_Ducey.Run;
end.

1 change: 0 additions & 1 deletion 01_Acey_Ducey/pascal/object-pascal/deck.pas
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ function TDeck.PlayerWins: Boolean;
end;

end.

1 change: 0 additions & 1 deletion 01_Acey_Ducey/pascal/object-pascal/game.pas
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,3 @@ procedure TGame.Run;
end;

end.

1 change: 0 additions & 1 deletion 01_Acey_Ducey/pascal/simple/aceyducey.pas
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,3 @@ function TryAgain: Boolean;
until not TryAgain;
WriteLN('O.K., HOPE YOU HAD FUN!');
end.

54 changes: 29 additions & 25 deletions 01_Acey_Ducey/python/acey_ducey_oo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#
######################################################


class Card:
def __init__(self, suit, rank):
self.suit = suit
Expand All @@ -19,14 +20,14 @@ def __init__(self, suit, rank):
def __str__(self):
r = self.rank
if r == 11:
r = 'J'
r = "J"
elif r == 12:
r = 'Q'
r = "Q"
elif r == 13:
r = 'K'
r = "K"
elif r == 14:
r = 'A'
return f'{r}{self.suit}'
r = "A"
return f"{r}{self.suit}"


class Deck:
Expand All @@ -35,12 +36,13 @@ def __init__(self):
self.build()

def build(self):
for suit in ['\u2665', '\u2666', '\u2663', '\u2660']:
for suit in ["\u2665", "\u2666", "\u2663", "\u2660"]:
for rank in range(2, 15):
self.cards.append(Card(suit, rank))

def shuffle(self):
import random

random.shuffle(self.cards)

def deal(self):
Expand Down Expand Up @@ -69,34 +71,34 @@ def play(self):
self.card_b = self.deck.deal()
card_b = self.card_b

print(f'You have:\t ${self.money} ')
print(f'Your cards:\t {card_a} {card_b}')
print(f"You have:\t ${self.money} ")
print(f"Your cards:\t {card_a} {card_b}")

bet = int(input('What is your bet? '))
bet = int(input("What is your bet? "))
player_card = self.deck.deal()
if 0 < bet <= self.money:

print(f'Your deal:\t {player_card}')
print(f"Your deal:\t {player_card}")
if card_a.rank < player_card.rank < card_b.rank:
print('You Win!')
print("You Win!")
self.money += bet
else:
print('You Lose!')
print("You Lose!")
self.money -= bet
self.not_done = False
else:
print('Chicken!')
print(f'Your deal should have been: {player_card}')
print("Chicken!")
print(f"Your deal should have been: {player_card}")
if card_a.rank < player_card.rank < card_b.rank:
print(f'You could have won!')
print(f"You could have won!")
else:
print(f'You would lose, so it was wise of you to chicken out!')
print(f"You would lose, so it was wise of you to chicken out!")

self.not_done = False
break

if len(self.deck.cards) <= 3:
print('You ran out of cards. Game over.')
print("You ran out of cards. Game over.")
self.not_done = False
break

Expand All @@ -107,22 +109,24 @@ def play(self):
self.not_done = False


if __name__ == '__main__':
print('''
if __name__ == "__main__":
print(
"""
Acey Ducey is a card game where you play against the computer.
The Dealer(computer) will deal two cards facing up.
You have an option to bet or not bet depending on whether or not you
You have an option to bet or not bet depending on whether or not you
feel the card will have a value between the first two.
If you do not want to bet input a 0
''')
"""
)
GAME_OVER = False

while not GAME_OVER:
game = Game()
game.play()
print(f'You have ${game.money} left')
print('Would you like to play again? (y/n)')
if input() == 'n':
print(f"You have ${game.money} left")
print("Would you like to play again? (y/n)")
if input() == "n":
GAME_OVER = True

print('\nThanks for playing!')
print("\nThanks for playing!")

0 comments on commit 375eb83

Please sign in to comment.