Skip to content

Commit 29210c1

Browse files
committed
Print cock differently
1 parent d4de99a commit 29210c1

3 files changed

Lines changed: 36 additions & 43 deletions

File tree

src/commands/penis.ts

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,9 @@ import type { ProcessableMessage } from "@/service/command.js";
66
import type { Penis } from "@/storage/db/model.js";
77
import { NormalDistribution, RandomNumberGenerator, SecureRandomSource } from "@/service/random.js";
88
import * as penis from "@/storage/penis.js";
9-
import { clamp } from "@/utils/math.js";
109

1110
import log from "@log";
1211

13-
export type Radius = 0 | 1 | 2 | 3;
14-
15-
const RADIUS_CHARS: Record<Radius, string> = {
16-
0: "",
17-
1: "‒",
18-
2: "=",
19-
3: "≡",
20-
};
21-
22-
const PENIS_LENGTH_MAX = 30;
23-
const PENIS_RADIUS_MAX = 3;
24-
25-
const sendPenis = async (
26-
user: User,
27-
message: ProcessableMessage,
28-
size: number,
29-
radius: Radius,
30-
measurement: Date = new Date(),
31-
): Promise<void> => {
32-
const radiusChar = RADIUS_CHARS[radius];
33-
const penis = `8${radiusChar.repeat(size | 0)}D`;
34-
const circumference = (Math.PI * radius * 2).toFixed(2);
35-
36-
await message.reply(
37-
`Pimmel von ${user}:\n${penis}\n(Länge: ${size.toFixed(2)} cm, Umfang: ${circumference} cm, Gemessen um ${time(measurement, TimestampStyles.LongDateTime)})`,
38-
);
39-
};
40-
41-
const isNewLongestDick = async (size: number): Promise<boolean> => {
42-
const oldLongest = (await penis.longestRecentMeasurement()) ?? -1;
43-
return oldLongest < size;
44-
};
45-
4612
const randomSource = new SecureRandomSource();
4713

4814
const lengthDistribution = new NormalDistribution(
@@ -64,6 +30,33 @@ const radiusDistribution = new NormalDistribution(11.85 / (Math.PI * 2), 1 / (Ma
6430

6531
const sizeGenerator = new RandomNumberGenerator(lengthDistribution, randomSource);
6632
const radiusGenerator = new RandomNumberGenerator(radiusDistribution, randomSource);
33+
34+
const RADIUS_CHARS = ["‒", "=", "≡"];
35+
36+
const sendPenis = async (
37+
user: User,
38+
message: ProcessableMessage,
39+
size: number,
40+
radius: number,
41+
measurement: Date,
42+
): Promise<void> => {
43+
const radiusChar =
44+
radius < radiusDistribution.mean
45+
? RADIUS_CHARS[0]
46+
: radius < radiusDistribution.mean + radiusDistribution.standardDeviation
47+
? RADIUS_CHARS[1]
48+
: RADIUS_CHARS[2];
49+
50+
const length = size | 0;
51+
52+
const penis = `8${radiusChar.repeat(length)}D`;
53+
const circumference = (Math.PI * radius * 2).toFixed(2);
54+
55+
await message.reply(
56+
`Pimmel von ${user}:\n${penis}\n(Länge: ${size.toFixed(2)} cm, Umfang: ${circumference} cm, Gemessen um ${time(measurement, TimestampStyles.LongDateTime)})`,
57+
);
58+
};
59+
6760
/**
6861
* Penis command. Displays the users penis length
6962
*/
@@ -152,10 +145,8 @@ export default class PenisCommand implements MessageCommand {
152145

153146
log.debug(`No recent measuring of ${userToMeasure.id} found. Creating Measurement.`);
154147

155-
const size = clamp(sizeGenerator.get(), 1, PENIS_LENGTH_MAX); // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
156-
157-
// TODO: Maye we want the radius to be integer only for display (and keep the float internally)
158-
const radius = clamp(Math.round(radiusGenerator.get()), 1, PENIS_RADIUS_MAX) as Radius; // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
148+
const size = Math.max(sizeGenerator.get(), 1);
149+
const radius = Math.max(radiusGenerator.get(), 1);
159150

160151
if (await isNewLongestDick(size)) {
161152
log.debug(`${userToMeasure} has the new longest dick with size ${size}`);
@@ -164,3 +155,8 @@ export default class PenisCommand implements MessageCommand {
164155
return await penis.insertMeasurement(userToMeasure, size, radius);
165156
}
166157
}
158+
159+
async function isNewLongestDick(size: number) {
160+
const oldLongest = (await penis.longestRecentMeasurement()) ?? -1;
161+
return oldLongest < size;
162+
}

src/storage/db/model.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Snowflake } from "discord.js";
22
import type { ColumnType, Generated, GeneratedAlways, Insertable, Selectable } from "kysely";
33

4-
import type { Radius } from "@/commands/penis.js";
5-
64
export type Date = ColumnType<string, string, string>; // TODO: Date is not supported by DB Driver
75

86
export interface Database {
@@ -114,7 +112,7 @@ export interface PenisTable extends AuditedTable {
114112

115113
userId: Snowflake;
116114
size: number;
117-
radius: Radius;
115+
radius: number;
118116
measuredAt: Generated<string>; // TODO: Date is not supported by the DB driver
119117
}
120118

src/storage/penis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once bun ships temporal
22
import type { Snowflake, User } from "discord.js";
33

4-
import type { Radius } from "@/commands/penis.js";
54
import type { Penis } from "@/storage/db/model.js";
65

76
import { getStartAndEndDay } from "@/utils/dateUtils.js";
@@ -11,7 +10,7 @@ import log from "@log";
1110
export function insertMeasurement(
1211
user: User,
1312
size: number,
14-
radius: Radius,
13+
radius: number,
1514
ctx = db(),
1615
): Promise<Penis> {
1716
log.debug(`Saving Penis Measurement for user ${user.id} with size ${size}`);

0 commit comments

Comments
 (0)